From 5bf055a62d63bee2ab63f9f0359e129247965af4 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Fri, 22 Nov 2019 16:32:24 +0100 Subject: [PATCH] winhttp: Use wide character string literals. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/winhttp/cookie.c | 6 +- dlls/winhttp/request.c | 333 ++++++++++++--------------------- dlls/winhttp/session.c | 67 +++---- dlls/winhttp/url.c | 26 +-- dlls/winhttp/winhttp_private.h | 8 - 5 files changed, 155 insertions(+), 285 deletions(-) diff --git a/dlls/winhttp/cookie.c b/dlls/winhttp/cookie.c index 3166290eab9..83efc7f85ce 100644 --- a/dlls/winhttp/cookie.c +++ b/dlls/winhttp/cookie.c @@ -262,8 +262,6 @@ static struct attr *parse_attr( const WCHAR *str, int *used ) BOOL set_cookies( struct request *request, const WCHAR *cookies ) { - static const WCHAR pathW[] = {'p','a','t','h',0}; - static const WCHAR domainW[] = {'d','o','m','a','i','n',0}; BOOL ret = FALSE; WCHAR *buffer, *p; WCHAR *cookie_domain = NULL, *cookie_path = NULL; @@ -287,12 +285,12 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies ) len = lstrlenW( p ); while (len && (attr = parse_attr( p, &used ))) { - if (!wcsicmp( attr->name, domainW )) + if (!wcsicmp( attr->name, L"domain" )) { domain = attr; cookie_domain = attr->value; } - else if (!wcsicmp( attr->name, pathW )) + else if (!wcsicmp( attr->name, L"path" )) { path = attr; cookie_path = attr->value; diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 0fd1d1abe9e..7c8e6ba89e0 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -41,136 +41,79 @@ WINE_DEFAULT_DEBUG_CHANNEL(winhttp); #define DEFAULT_KEEP_ALIVE_TIMEOUT 30000 -static const WCHAR attr_accept[] = {'A','c','c','e','p','t',0}; -static const WCHAR attr_accept_charset[] = {'A','c','c','e','p','t','-','C','h','a','r','s','e','t', 0}; -static const WCHAR attr_accept_encoding[] = {'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0}; -static const WCHAR attr_accept_language[] = {'A','c','c','e','p','t','-','L','a','n','g','u','a','g','e',0}; -static const WCHAR attr_accept_ranges[] = {'A','c','c','e','p','t','-','R','a','n','g','e','s',0}; -static const WCHAR attr_age[] = {'A','g','e',0}; -static const WCHAR attr_allow[] = {'A','l','l','o','w',0}; -static const WCHAR attr_authorization[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',0}; -static const WCHAR attr_cache_control[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l',0}; -static const WCHAR attr_connection[] = {'C','o','n','n','e','c','t','i','o','n',0}; -static const WCHAR attr_content_base[] = {'C','o','n','t','e','n','t','-','B','a','s','e',0}; -static const WCHAR attr_content_encoding[] = {'C','o','n','t','e','n','t','-','E','n','c','o','d','i','n','g',0}; -static const WCHAR attr_content_id[] = {'C','o','n','t','e','n','t','-','I','D',0}; -static const WCHAR attr_content_language[] = {'C','o','n','t','e','n','t','-','L','a','n','g','u','a','g','e',0}; -static const WCHAR attr_content_length[] = {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0}; -static const WCHAR attr_content_location[] = {'C','o','n','t','e','n','t','-','L','o','c','a','t','i','o','n',0}; -static const WCHAR attr_content_md5[] = {'C','o','n','t','e','n','t','-','M','D','5',0}; -static const WCHAR attr_content_range[] = {'C','o','n','t','e','n','t','-','R','a','n','g','e',0}; -static const WCHAR attr_content_transfer_encoding[] = {'C','o','n','t','e','n','t','-','T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0}; -static const WCHAR attr_content_type[] = {'C','o','n','t','e','n','t','-','T','y','p','e',0}; -static const WCHAR attr_cookie[] = {'C','o','o','k','i','e',0}; -static const WCHAR attr_date[] = {'D','a','t','e',0}; -static const WCHAR attr_from[] = {'F','r','o','m',0}; -static const WCHAR attr_etag[] = {'E','T','a','g',0}; -static const WCHAR attr_expect[] = {'E','x','p','e','c','t',0}; -static const WCHAR attr_expires[] = {'E','x','p','i','r','e','s',0}; -static const WCHAR attr_host[] = {'H','o','s','t',0}; -static const WCHAR attr_if_match[] = {'I','f','-','M','a','t','c','h',0}; -static const WCHAR attr_if_modified_since[] = {'I','f','-','M','o','d','i','f','i','e','d','-','S','i','n','c','e',0}; -static const WCHAR attr_if_none_match[] = {'I','f','-','N','o','n','e','-','M','a','t','c','h',0}; -static const WCHAR attr_if_range[] = {'I','f','-','R','a','n','g','e',0}; -static const WCHAR attr_if_unmodified_since[] = {'I','f','-','U','n','m','o','d','i','f','i','e','d','-','S','i','n','c','e',0}; -static const WCHAR attr_last_modified[] = {'L','a','s','t','-','M','o','d','i','f','i','e','d',0}; -static const WCHAR attr_location[] = {'L','o','c','a','t','i','o','n',0}; -static const WCHAR attr_max_forwards[] = {'M','a','x','-','F','o','r','w','a','r','d','s',0}; -static const WCHAR attr_mime_version[] = {'M','i','m','e','-','V','e','r','s','i','o','n',0}; -static const WCHAR attr_pragma[] = {'P','r','a','g','m','a',0}; -static const WCHAR attr_proxy_authenticate[] = {'P','r','o','x','y','-','A','u','t','h','e','n','t','i','c','a','t','e',0}; -static const WCHAR attr_proxy_authorization[] = {'P','r','o','x','y','-','A','u','t','h','o','r','i','z','a','t','i','o','n',0}; -static const WCHAR attr_proxy_connection[] = {'P','r','o','x','y','-','C','o','n','n','e','c','t','i','o','n',0}; -static const WCHAR attr_public[] = {'P','u','b','l','i','c',0}; -static const WCHAR attr_range[] = {'R','a','n','g','e',0}; -static const WCHAR attr_referer[] = {'R','e','f','e','r','e','r',0}; -static const WCHAR attr_retry_after[] = {'R','e','t','r','y','-','A','f','t','e','r',0}; -static const WCHAR attr_server[] = {'S','e','r','v','e','r',0}; -static const WCHAR attr_set_cookie[] = {'S','e','t','-','C','o','o','k','i','e',0}; -static const WCHAR attr_status[] = {'S','t','a','t','u','s',0}; -static const WCHAR attr_transfer_encoding[] = {'T','r','a','n','s','f','e','r','-','E','n','c','o','d','i','n','g',0}; -static const WCHAR attr_unless_modified_since[] = {'U','n','l','e','s','s','-','M','o','d','i','f','i','e','d','-','S','i','n','c','e',0}; -static const WCHAR attr_upgrade[] = {'U','p','g','r','a','d','e',0}; -static const WCHAR attr_uri[] = {'U','R','I',0}; -static const WCHAR attr_user_agent[] = {'U','s','e','r','-','A','g','e','n','t',0}; -static const WCHAR attr_vary[] = {'V','a','r','y',0}; -static const WCHAR attr_via[] = {'V','i','a',0}; -static const WCHAR attr_warning[] = {'W','a','r','n','i','n','g',0}; -static const WCHAR attr_www_authenticate[] = {'W','W','W','-','A','u','t','h','e','n','t','i','c','a','t','e',0}; - static const WCHAR *attribute_table[] = { - attr_mime_version, /* WINHTTP_QUERY_MIME_VERSION = 0 */ - attr_content_type, /* WINHTTP_QUERY_CONTENT_TYPE = 1 */ - attr_content_transfer_encoding, /* WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2 */ - attr_content_id, /* WINHTTP_QUERY_CONTENT_ID = 3 */ + L"Mime-Version", /* WINHTTP_QUERY_MIME_VERSION = 0 */ + L"Content-Type" , /* WINHTTP_QUERY_CONTENT_TYPE = 1 */ + L"Content-Transfer-Encoding", /* WINHTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2 */ + L"Content-ID", /* WINHTTP_QUERY_CONTENT_ID = 3 */ NULL, /* WINHTTP_QUERY_CONTENT_DESCRIPTION = 4 */ - attr_content_length, /* WINHTTP_QUERY_CONTENT_LENGTH = 5 */ - attr_content_language, /* WINHTTP_QUERY_CONTENT_LANGUAGE = 6 */ - attr_allow, /* WINHTTP_QUERY_ALLOW = 7 */ - attr_public, /* WINHTTP_QUERY_PUBLIC = 8 */ - attr_date, /* WINHTTP_QUERY_DATE = 9 */ - attr_expires, /* WINHTTP_QUERY_EXPIRES = 10 */ - attr_last_modified, /* WINHTTP_QUERY_LAST_MODIFIEDcw = 11 */ + L"Content-Length", /* WINHTTP_QUERY_CONTENT_LENGTH = 5 */ + L"Content-Language", /* WINHTTP_QUERY_CONTENT_LANGUAGE = 6 */ + L"Allow", /* WINHTTP_QUERY_ALLOW = 7 */ + L"Public", /* WINHTTP_QUERY_PUBLIC = 8 */ + L"Date", /* WINHTTP_QUERY_DATE = 9 */ + L"Expires", /* WINHTTP_QUERY_EXPIRES = 10 */ + L"Last-Modified", /* WINHTTP_QUERY_LAST_MODIFIEDcw = 11 */ NULL, /* WINHTTP_QUERY_MESSAGE_ID = 12 */ - attr_uri, /* WINHTTP_QUERY_URI = 13 */ - attr_from, /* WINHTTP_QUERY_DERIVED_FROM = 14 */ + L"URI", /* WINHTTP_QUERY_URI = 13 */ + L"From", /* WINHTTP_QUERY_DERIVED_FROM = 14 */ NULL, /* WINHTTP_QUERY_COST = 15 */ NULL, /* WINHTTP_QUERY_LINK = 16 */ - attr_pragma, /* WINHTTP_QUERY_PRAGMA = 17 */ + L"Pragma", /* WINHTTP_QUERY_PRAGMA = 17 */ NULL, /* WINHTTP_QUERY_VERSION = 18 */ - attr_status, /* WINHTTP_QUERY_STATUS_CODE = 19 */ + L"Status", /* WINHTTP_QUERY_STATUS_CODE = 19 */ NULL, /* WINHTTP_QUERY_STATUS_TEXT = 20 */ NULL, /* WINHTTP_QUERY_RAW_HEADERS = 21 */ NULL, /* WINHTTP_QUERY_RAW_HEADERS_CRLF = 22 */ - attr_connection, /* WINHTTP_QUERY_CONNECTION = 23 */ - attr_accept, /* WINHTTP_QUERY_ACCEPT = 24 */ - attr_accept_charset, /* WINHTTP_QUERY_ACCEPT_CHARSET = 25 */ - attr_accept_encoding, /* WINHTTP_QUERY_ACCEPT_ENCODING = 26 */ - attr_accept_language, /* WINHTTP_QUERY_ACCEPT_LANGUAGE = 27 */ - attr_authorization, /* WINHTTP_QUERY_AUTHORIZATION = 28 */ - attr_content_encoding, /* WINHTTP_QUERY_CONTENT_ENCODING = 29 */ + L"Connection", /* WINHTTP_QUERY_CONNECTION = 23 */ + L"Accept", /* WINHTTP_QUERY_ACCEPT = 24 */ + L"Accept-Charset", /* WINHTTP_QUERY_ACCEPT_CHARSET = 25 */ + L"Accept-Encoding", /* WINHTTP_QUERY_ACCEPT_ENCODING = 26 */ + L"Accept-Language", /* WINHTTP_QUERY_ACCEPT_LANGUAGE = 27 */ + L"Authorization", /* WINHTTP_QUERY_AUTHORIZATION = 28 */ + L"Content-Encoding", /* WINHTTP_QUERY_CONTENT_ENCODING = 29 */ NULL, /* WINHTTP_QUERY_FORWARDED = 30 */ NULL, /* WINHTTP_QUERY_FROM = 31 */ - attr_if_modified_since, /* WINHTTP_QUERY_IF_MODIFIED_SINCE = 32 */ - attr_location, /* WINHTTP_QUERY_LOCATION = 33 */ + L"If-Modified-Since", /* WINHTTP_QUERY_IF_MODIFIED_SINCE = 32 */ + L"Location", /* WINHTTP_QUERY_LOCATION = 33 */ NULL, /* WINHTTP_QUERY_ORIG_URI = 34 */ - attr_referer, /* WINHTTP_QUERY_REFERER = 35 */ - attr_retry_after, /* WINHTTP_QUERY_RETRY_AFTER = 36 */ - attr_server, /* WINHTTP_QUERY_SERVER = 37 */ + L"Referer", /* WINHTTP_QUERY_REFERER = 35 */ + L"Retry-After", /* WINHTTP_QUERY_RETRY_AFTER = 36 */ + L"Server", /* WINHTTP_QUERY_SERVER = 37 */ NULL, /* WINHTTP_TITLE = 38 */ - attr_user_agent, /* WINHTTP_QUERY_USER_AGENT = 39 */ - attr_www_authenticate, /* WINHTTP_QUERY_WWW_AUTHENTICATE = 40 */ - attr_proxy_authenticate, /* WINHTTP_QUERY_PROXY_AUTHENTICATE = 41 */ - attr_accept_ranges, /* WINHTTP_QUERY_ACCEPT_RANGES = 42 */ - attr_set_cookie, /* WINHTTP_QUERY_SET_COOKIE = 43 */ - attr_cookie, /* WINHTTP_QUERY_COOKIE = 44 */ + L"User-Agent", /* WINHTTP_QUERY_USER_AGENT = 39 */ + L"WWW-Authenticate", /* WINHTTP_QUERY_WWW_AUTHENTICATE = 40 */ + L"Proxy-Authenticate", /* WINHTTP_QUERY_PROXY_AUTHENTICATE = 41 */ + L"Accept-Ranges", /* WINHTTP_QUERY_ACCEPT_RANGES = 42 */ + L"Set-Cookie", /* WINHTTP_QUERY_SET_COOKIE = 43 */ + L"Cookie", /* WINHTTP_QUERY_COOKIE = 44 */ NULL, /* WINHTTP_QUERY_REQUEST_METHOD = 45 */ NULL, /* WINHTTP_QUERY_REFRESH = 46 */ NULL, /* WINHTTP_QUERY_CONTENT_DISPOSITION = 47 */ - attr_age, /* WINHTTP_QUERY_AGE = 48 */ - attr_cache_control, /* WINHTTP_QUERY_CACHE_CONTROL = 49 */ - attr_content_base, /* WINHTTP_QUERY_CONTENT_BASE = 50 */ - attr_content_location, /* WINHTTP_QUERY_CONTENT_LOCATION = 51 */ - attr_content_md5, /* WINHTTP_QUERY_CONTENT_MD5 = 52 */ - attr_content_range, /* WINHTTP_QUERY_CONTENT_RANGE = 53 */ - attr_etag, /* WINHTTP_QUERY_ETAG = 54 */ - attr_host, /* WINHTTP_QUERY_HOST = 55 */ - attr_if_match, /* WINHTTP_QUERY_IF_MATCH = 56 */ - attr_if_none_match, /* WINHTTP_QUERY_IF_NONE_MATCH = 57 */ - attr_if_range, /* WINHTTP_QUERY_IF_RANGE = 58 */ - attr_if_unmodified_since, /* WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59 */ - attr_max_forwards, /* WINHTTP_QUERY_MAX_FORWARDS = 60 */ - attr_proxy_authorization, /* WINHTTP_QUERY_PROXY_AUTHORIZATION = 61 */ - attr_range, /* WINHTTP_QUERY_RANGE = 62 */ - attr_transfer_encoding, /* WINHTTP_QUERY_TRANSFER_ENCODING = 63 */ - attr_upgrade, /* WINHTTP_QUERY_UPGRADE = 64 */ - attr_vary, /* WINHTTP_QUERY_VARY = 65 */ - attr_via, /* WINHTTP_QUERY_VIA = 66 */ - attr_warning, /* WINHTTP_QUERY_WARNING = 67 */ - attr_expect, /* WINHTTP_QUERY_EXPECT = 68 */ - attr_proxy_connection, /* WINHTTP_QUERY_PROXY_CONNECTION = 69 */ - attr_unless_modified_since, /* WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70 */ + L"Age", /* WINHTTP_QUERY_AGE = 48 */ + L"Cache-Control", /* WINHTTP_QUERY_CACHE_CONTROL = 49 */ + L"Content-Base", /* WINHTTP_QUERY_CONTENT_BASE = 50 */ + L"Content-Location", /* WINHTTP_QUERY_CONTENT_LOCATION = 51 */ + L"Content-MD5", /* WINHTTP_QUERY_CONTENT_MD5 = 52 */ + L"Content-Range", /* WINHTTP_QUERY_CONTENT_RANGE = 53 */ + L"ETag", /* WINHTTP_QUERY_ETAG = 54 */ + L"Host", /* WINHTTP_QUERY_HOST = 55 */ + L"If-Match", /* WINHTTP_QUERY_IF_MATCH = 56 */ + L"If-None-Match", /* WINHTTP_QUERY_IF_NONE_MATCH = 57 */ + L"If-Range", /* WINHTTP_QUERY_IF_RANGE = 58 */ + L"If-Unmodified-Since", /* WINHTTP_QUERY_IF_UNMODIFIED_SINCE = 59 */ + L"Max-Forwards", /* WINHTTP_QUERY_MAX_FORWARDS = 60 */ + L"Proxy-Authorization", /* WINHTTP_QUERY_PROXY_AUTHORIZATION = 61 */ + L"Range", /* WINHTTP_QUERY_RANGE = 62 */ + L"Transfer-Encoding", /* WINHTTP_QUERY_TRANSFER_ENCODING = 63 */ + L"Upgrade", /* WINHTTP_QUERY_UPGRADE = 64 */ + L"Vary", /* WINHTTP_QUERY_VARY = 65 */ + L"Via", /* WINHTTP_QUERY_VIA = 66 */ + L"Warning", /* WINHTTP_QUERY_WARNING = 67 */ + L"Expect", /* WINHTTP_QUERY_EXPECT = 68 */ + L"Proxy-Connection", /* WINHTTP_QUERY_PROXY_CONNECTION = 69 */ + L"Unless-Modified-Since", /* WINHTTP_QUERY_UNLESS_MODIFIED_SINCE = 70 */ NULL, /* WINHTTP_QUERY_PROXY_SUPPORT = 75 */ NULL, /* WINHTTP_QUERY_AUTHENTICATION_INFO = 76 */ NULL, /* WINHTTP_QUERY_PASSPORT_URLS = 77 */ @@ -543,14 +486,11 @@ BOOL WINAPI WinHttpAddRequestHeaders( HINTERNET hrequest, LPCWSTR headers, DWORD static WCHAR *build_absolute_request_path( struct request *request, const WCHAR **path ) { - static const WCHAR http[] = {'h','t','t','p',0}; - static const WCHAR https[] = {'h','t','t','p','s',0}; - static const WCHAR fmt[] = {'%','s',':','/','/','%','s',0}; const WCHAR *scheme; WCHAR *ret; int len, offset; - scheme = (request->netconn ? request->netconn->secure : (request->hdr.flags & WINHTTP_FLAG_SECURE)) ? https : http; + scheme = (request->netconn ? request->netconn->secure : (request->hdr.flags & WINHTTP_FLAG_SECURE)) ? L"https" : L"http"; len = lstrlenW( scheme ) + lstrlenW( request->connect->hostname ) + 4; /* '://' + nul */ if (request->connect->hostport) len += 6; /* ':' between host and port, up to 5 for port */ @@ -558,11 +498,10 @@ static WCHAR *build_absolute_request_path( struct request *request, const WCHAR len += lstrlenW( request->path ); if ((ret = heap_alloc( len * sizeof(WCHAR) ))) { - offset = swprintf( ret, len, fmt, scheme, request->connect->hostname ); + offset = swprintf( ret, len, L"%s://%s", scheme, request->connect->hostname ); if (request->connect->hostport) { - static const WCHAR port_fmt[] = {':','%','u',0}; - offset += swprintf( ret + offset, len - offset, port_fmt, request->connect->hostport ); + offset += swprintf( ret + offset, len - offset, L":%u", request->connect->hostport ); } lstrcpyW( ret + offset, request->path ); if (path) *path = ret + offset; @@ -573,8 +512,6 @@ static WCHAR *build_absolute_request_path( struct request *request, const WCHAR static WCHAR *build_request_string( struct request *request ) { - static const WCHAR spaceW[] = {' ',0}, crlfW[] = {'\r','\n',0}, colonW[] = {':',' ',0}; - static const WCHAR twocrlfW[] = {'\r','\n','\r','\n',0}; WCHAR *path, *ret; unsigned int i, len; @@ -595,22 +532,22 @@ static WCHAR *build_request_string( struct request *request ) if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) { lstrcpyW( ret, request->verb ); - lstrcatW( ret, spaceW ); + lstrcatW( ret, L" " ); lstrcatW( ret, path ); - lstrcatW( ret, spaceW ); + lstrcatW( ret, L" " ); lstrcatW( ret, request->version ); for (i = 0; i < request->num_headers; i++) { if (request->headers[i].is_request) { - lstrcatW( ret, crlfW ); + lstrcatW( ret, L"\r\n" ); lstrcatW( ret, request->headers[i].field ); - lstrcatW( ret, colonW ); + lstrcatW( ret, L": " ); lstrcatW( ret, request->headers[i].value ); } } - lstrcatW( ret, twocrlfW ); + lstrcatW( ret, L"\r\n\r\n" ); } if (path != request->path) heap_free( path ); @@ -850,12 +787,6 @@ BOOL WINAPI WinHttpQueryHeaders( HINTERNET hrequest, DWORD level, LPCWSTR name, return ret; } -static const WCHAR basicW[] = {'B','a','s','i','c',0}; -static const WCHAR ntlmW[] = {'N','T','L','M',0}; -static const WCHAR passportW[] = {'P','a','s','s','p','o','r','t',0}; -static const WCHAR digestW[] = {'D','i','g','e','s','t',0}; -static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',0}; - static const struct { const WCHAR *str; @@ -864,11 +795,11 @@ static const struct } auth_schemes[] = { - { basicW, ARRAY_SIZE(basicW) - 1, WINHTTP_AUTH_SCHEME_BASIC }, - { ntlmW, ARRAY_SIZE(ntlmW) - 1, WINHTTP_AUTH_SCHEME_NTLM }, - { passportW, ARRAY_SIZE(passportW) - 1, WINHTTP_AUTH_SCHEME_PASSPORT }, - { digestW, ARRAY_SIZE(digestW) - 1, WINHTTP_AUTH_SCHEME_DIGEST }, - { negotiateW, ARRAY_SIZE(negotiateW) - 1, WINHTTP_AUTH_SCHEME_NEGOTIATE } + { L"Basic", ARRAY_SIZE(L"Basic") - 1, WINHTTP_AUTH_SCHEME_BASIC }, + { L"NTLM", ARRAY_SIZE(L"NTLM") - 1, WINHTTP_AUTH_SCHEME_NTLM }, + { L"Passport", ARRAY_SIZE(L"Passport") - 1, WINHTTP_AUTH_SCHEME_PASSPORT }, + { L"Digest", ARRAY_SIZE(L"Digest") - 1, WINHTTP_AUTH_SCHEME_DIGEST }, + { L"Negotiate", ARRAY_SIZE(L"Negotiate") - 1, WINHTTP_AUTH_SCHEME_NEGOTIATE } }; static enum auth_scheme scheme_from_flag( DWORD flag ) @@ -1147,7 +1078,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem case WINHTTP_AUTH_TARGET_SERVER: has_auth_value = get_authvalue( request, WINHTTP_QUERY_WWW_AUTHENTICATE, scheme_flag, auth_value, len ); auth_ptr = &request->authinfo; - auth_target = attr_authorization; + auth_target = L"Authorization"; if (request->creds[TARGET_SERVER][scheme].username) { if (scheme != SCHEME_BASIC && !has_auth_value) return FALSE; @@ -1166,7 +1097,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem if (!get_authvalue( request, WINHTTP_QUERY_PROXY_AUTHENTICATE, scheme_flag, auth_value, len )) return FALSE; auth_ptr = &request->proxy_authinfo; - auth_target = attr_proxy_authorization; + auth_target = L"Proxy-Authorization"; if (request->creds[TARGET_PROXY][scheme].username) { username = request->creds[TARGET_PROXY][scheme].username; @@ -1362,19 +1293,15 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem static WCHAR *build_proxy_connect_string( struct request *request ) { - static const WCHAR fmtW[] = {'%','s',':','%','u',0}; - static const WCHAR connectW[] = {'C','O','N','N','E','C','T', 0}; - static const WCHAR spaceW[] = {' ',0}, crlfW[] = {'\r','\n',0}, colonW[] = {':',' ',0}; - static const WCHAR twocrlfW[] = {'\r','\n','\r','\n',0}; WCHAR *ret, *host; unsigned int i; int len = lstrlenW( request->connect->hostname ) + 7; if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return NULL; - len = swprintf( host, len, fmtW, request->connect->hostname, request->connect->hostport ); + len = swprintf( host, len, L"%s:%u", request->connect->hostname, request->connect->hostport ); - len += ARRAY_SIZE(connectW); - len += ARRAY_SIZE(http1_1); + len += ARRAY_SIZE(L"CONNECT"); + len += ARRAY_SIZE(L"HTTP/1.1"); for (i = 0; i < request->num_headers; i++) { @@ -1385,23 +1312,23 @@ static WCHAR *build_proxy_connect_string( struct request *request ) if ((ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) { - lstrcpyW( ret, connectW ); - lstrcatW( ret, spaceW ); + lstrcpyW( ret, L"CONNECT" ); + lstrcatW( ret, L" " ); lstrcatW( ret, host ); - lstrcatW( ret, spaceW ); - lstrcatW( ret, http1_1 ); + lstrcatW( ret, L" " ); + lstrcatW( ret, L"HTTP/1.1" ); for (i = 0; i < request->num_headers; i++) { if (request->headers[i].is_request) { - lstrcatW( ret, crlfW ); + lstrcatW( ret, L"\r\n" ); lstrcatW( ret, request->headers[i].field ); - lstrcatW( ret, colonW ); + lstrcatW( ret, L": " ); lstrcatW( ret, request->headers[i].value ); } } - lstrcatW( ret, twocrlfW ); + lstrcatW( ret, L"\r\n\r\n" ); } heap_free( host ); @@ -1768,7 +1695,6 @@ static BOOL add_host_header( struct request *request, DWORD modifier ) BOOL ret; DWORD len; WCHAR *host; - static const WCHAR fmt[] = {'%','s',':','%','u',0}; struct connect *connect = request->connect; INTERNET_PORT port; @@ -1776,12 +1702,12 @@ static BOOL add_host_header( struct request *request, DWORD modifier ) if (port == INTERNET_DEFAULT_HTTP_PORT || port == INTERNET_DEFAULT_HTTPS_PORT) { - return process_header( request, attr_host, connect->hostname, modifier, TRUE ); + return process_header( request, L"Host", connect->hostname, modifier, TRUE ); } len = lstrlenW( connect->hostname ) + 7; /* sizeof(":65335") */ if (!(host = heap_alloc( len * sizeof(WCHAR) ))) return FALSE; - swprintf( host, len, fmt, connect->hostname, port ); - ret = process_header( request, attr_host, host, modifier, TRUE ); + swprintf( host, len, L"%s:%u", connect->hostname, port ); + ret = process_header( request, L"Host", host, modifier, TRUE ); heap_free( host ); return ret; } @@ -1921,8 +1847,6 @@ static BOOL refill_buffer( struct request *request, BOOL notify ) static void finished_reading( struct request *request ) { - static const WCHAR closeW[] = {'c','l','o','s','e',0}; - BOOL close = FALSE; WCHAR connection[20]; DWORD size = sizeof(connection); @@ -1933,9 +1857,9 @@ static void finished_reading( struct request *request ) else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) || query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL )) { - if (!wcsicmp( connection, closeW )) close = TRUE; + if (!wcsicmp( connection, L"close" )) close = TRUE; } - else if (!wcscmp( request->version, http1_0 )) close = TRUE; + else if (!wcscmp( request->version, L"HTTP/1.0" )) close = TRUE; if (close) { close_connection( request ); @@ -2199,10 +2123,6 @@ static char *build_wire_request( struct request *request, DWORD *len ) static BOOL send_request( struct request *request, const WCHAR *headers, DWORD headers_len, void *optional, DWORD optional_len, DWORD total_len, DWORD_PTR context, BOOL async ) { - static const WCHAR keep_alive[] = {'K','e','e','p','-','A','l','i','v','e',0}; - static const WCHAR no_cache[] = {'n','o','-','c','a','c','h','e',0}; - static const WCHAR length_fmt[] = {'%','l','d',0}; - BOOL ret = FALSE; struct connect *connect = request->connect; struct session *session = connect->session; @@ -2214,7 +2134,7 @@ static BOOL send_request( struct request *request, const WCHAR *headers, DWORD h drain_content( request ); if (session->agent) - process_header( request, attr_user_agent, session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); + process_header( request, L"User-Agent", session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); if (connect->hostname) add_host_header( request, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW ); @@ -2222,20 +2142,20 @@ static BOOL send_request( struct request *request, const WCHAR *headers, DWORD h if (request->creds[TARGET_SERVER][SCHEME_BASIC].username) do_authorization( request, WINHTTP_AUTH_TARGET_SERVER, WINHTTP_AUTH_SCHEME_BASIC ); - if (total_len || (request->verb && !wcscmp( request->verb, postW ))) + if (total_len || (request->verb && !wcscmp( request->verb, L"POST" ))) { WCHAR length[21]; /* decimal long int + null */ - swprintf( length, ARRAY_SIZE(length), length_fmt, total_len ); - process_header( request, attr_content_length, length, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); + swprintf( length, ARRAY_SIZE(length), L"%ld", total_len ); + process_header( request, L"Content-Length", length, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); } if (!(request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE)) { - process_header( request, attr_connection, keep_alive, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); + process_header( request, L"Connection", L"Keep-Alive", WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); } if (request->hdr.flags & WINHTTP_FLAG_REFRESH) { - process_header( request, attr_pragma, no_cache, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); - process_header( request, attr_cache_control, no_cache, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); + process_header( request, L"Pragma", L"no-cache", WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); + process_header( request, L"Cache-Control", L"no-cache", WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE ); } if (headers && !add_request_headers( request, headers, headers_len, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE )) { @@ -2452,7 +2372,7 @@ static DWORD set_content_length( struct request *request, DWORD status ) WCHAR encoding[20]; DWORD buflen = sizeof(request->content_length); - if (status == HTTP_STATUS_NO_CONTENT || status == HTTP_STATUS_NOT_MODIFIED || !wcscmp( request->verb, headW )) + if (status == HTTP_STATUS_NO_CONTENT || status == HTTP_STATUS_NOT_MODIFIED || !wcscmp( request->verb, L"HEAD" )) request->content_length = 0; else { @@ -2462,7 +2382,7 @@ static DWORD set_content_length( struct request *request, DWORD status ) buflen = sizeof(encoding); if (query_headers( request, WINHTTP_QUERY_TRANSFER_ENCODING, NULL, encoding, &buflen, NULL ) && - !wcsicmp( encoding, chunkedW )) + !wcsicmp( encoding, L"chunked" )) { request->content_length = ~0u; request->read_chunked = TRUE; @@ -2517,8 +2437,6 @@ static BOOL read_line( struct request *request, char *buffer, DWORD *len ) static BOOL read_reply( struct request *request ) { - static const WCHAR crlf[] = {'\r','\n',0}; - char buffer[MAX_REPLY_LEN]; DWORD buflen, len, offset, crlf_len = 2; /* lstrlenW(crlf) */ char *status_code, *status_text; @@ -2549,7 +2467,7 @@ static BOOL read_reply( struct request *request ) /* we rely on the fact that the protocol is ascii */ MultiByteToWideChar( CP_ACP, 0, status_code, len, status_codeW, len ); status_codeW[len] = 0; - if (!(process_header( request, attr_status, status_codeW, + if (!(process_header( request, L"Status", status_codeW, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE, FALSE ))) return FALSE; @@ -2571,7 +2489,7 @@ static BOOL read_reply( struct request *request ) len = max( buflen + crlf_len, INITIAL_HEADER_BUFFER_LEN ); if (!(raw_headers = heap_alloc( len * sizeof(WCHAR) ))) return FALSE; MultiByteToWideChar( CP_ACP, 0, buffer, buflen, raw_headers, buflen ); - memcpy( raw_headers + buflen - 1, crlf, sizeof(crlf) ); + memcpy( raw_headers + buflen - 1, L"\r\n", sizeof(L"\r\n") ); heap_free( request->raw_headers ); request->raw_headers = raw_headers; @@ -2594,7 +2512,7 @@ static BOOL read_reply( struct request *request ) } if (!*buffer) { - memcpy( raw_headers + offset, crlf, sizeof(crlf) ); + memcpy( raw_headers + offset, L"\r\n", sizeof(L"\r\n") ); break; } MultiByteToWideChar( CP_ACP, 0, buffer, buflen, raw_headers + offset, buflen ); @@ -2606,7 +2524,7 @@ static BOOL read_reply( struct request *request ) break; } free_header( header ); - memcpy( raw_headers + offset + buflen - 1, crlf, sizeof(crlf) ); + memcpy( raw_headers + offset + buflen - 1, L"\r\n", sizeof(L"\r\n") ); offset += buflen + crlf_len - 1; } @@ -2621,7 +2539,7 @@ static void record_cookies( struct request *request ) for (i = 0; i < request->num_headers; i++) { struct header *set_cookie = &request->headers[i]; - if (!wcsicmp( set_cookie->field, attr_set_cookie ) && !set_cookie->is_request) + if (!wcsicmp( set_cookie->field, L"Set-Cookie" ) && !set_cookie->is_request) { set_cookies( request, set_cookie->value ); } @@ -2674,7 +2592,7 @@ static BOOL handle_redirect( struct request *request, DWORD status ) len = lstrlenW( request->path ) + 1 + len_loc; if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; lstrcpyW( path, request->path ); - lstrcatW( path, slashW ); + lstrcatW( path, L"/" ); memcpy( path + lstrlenW(path), location, len_loc * sizeof(WCHAR) ); path[len_loc] = 0; } @@ -2732,17 +2650,17 @@ static BOOL handle_redirect( struct request *request, DWORD status ) memcpy( request->path, uc.lpszUrlPath, (len + 1) * sizeof(WCHAR) ); request->path[len] = 0; } - else request->path = strdupW( slashW ); + else request->path = strdupW( L"/" ); } /* remove content-type/length headers */ - if ((index = get_header_index( request, attr_content_type, 0, TRUE )) >= 0) delete_header( request, index ); - if ((index = get_header_index( request, attr_content_length, 0, TRUE )) >= 0 ) delete_header( request, index ); + if ((index = get_header_index( request, L"Content-Type", 0, TRUE )) >= 0) delete_header( request, index ); + if ((index = get_header_index( request, L"Content-Length", 0, TRUE )) >= 0 ) delete_header( request, index ); - if (status != HTTP_STATUS_REDIRECT_KEEP_VERB && !wcscmp( request->verb, postW )) + if (status != HTTP_STATUS_REDIRECT_KEEP_VERB && !wcscmp( request->verb, L"POST" )) { heap_free( request->verb ); - request->verb = strdupW( getW ); + request->verb = strdupW( L"GET" ); request->optional = NULL; request->optional_len = 0; } @@ -2770,12 +2688,11 @@ static BOOL is_passport_request( struct request *request ) static BOOL handle_passport_redirect( struct request *request ) { - static const WCHAR status401W[] = {'4','0','1',0}; DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE; int i, len = lstrlenW( request->raw_headers ); WCHAR *p = request->raw_headers; - if (!process_header( request, attr_status, status401W, flags, FALSE )) return FALSE; + if (!process_header( request, L"Status", L"401", flags, FALSE )) return FALSE; for (i = 0; i < len; i++) { @@ -3560,13 +3477,9 @@ static HRESULT WINAPI winhttp_request_Open( BSTR url, VARIANT async ) { - static const WCHAR typeW[] = {'*','/','*',0}; - static const WCHAR *acceptW[] = {typeW, NULL}; static const WCHAR httpsW[] = {'h','t','t','p','s'}; - static const WCHAR user_agentW[] = { - 'M','o','z','i','l','l','a','/','4','.','0',' ','(','c','o','m','p','a','t','i','b','l','e',';',' ', - 'W','i','n','3','2',';',' ','W','i','n','H','t','t','p','.','W','i','n','H','t','t','p', - 'R','e','q','u','e','s','t','.','5',')',0}; + static const WCHAR *acceptW[] = {L"*/*", NULL}; + static const WCHAR user_agentW[] = L"Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)"; struct winhttp_request *request = impl_from_IWinHttpRequest( iface ); URL_COMPONENTS uc; WCHAR *hostname, *path = NULL, *verb = NULL; @@ -3656,8 +3569,6 @@ static HRESULT WINAPI winhttp_request_SetRequestHeader( BSTR header, BSTR value ) { - static const WCHAR fmtW[] = {'%','s',':',' ','%','s','\r','\n',0}; - static const WCHAR emptyW[] = {0}; struct winhttp_request *request = impl_from_IWinHttpRequest( iface ); DWORD len, err = ERROR_SUCCESS; WCHAR *str; @@ -3684,7 +3595,7 @@ static HRESULT WINAPI winhttp_request_SetRequestHeader( err = ERROR_OUTOFMEMORY; goto done; } - swprintf( str, len + 1, fmtW, header, value ? value : emptyW ); + swprintf( str, len + 1, L"%s: %s\r\n", header, value ? value : L"" ); if (!WinHttpAddRequestHeaders( request->hrequest, str, len, WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_REPLACE )) { @@ -3843,7 +3754,7 @@ static HRESULT request_receive( struct winhttp_request *request ) return HRESULT_FROM_WIN32( GetLastError() ); } if ((err = wait_for_completion( request ))) return HRESULT_FROM_WIN32( err ); - if (!wcscmp( request->verb, headW )) + if (!wcscmp( request->verb, L"HEAD" )) { request->state = REQUEST_STATE_RESPONSE_RECEIVED; return S_OK; @@ -3914,15 +3825,13 @@ static DWORD request_set_parameters( struct winhttp_request *request ) static void request_set_utf8_content_type( struct winhttp_request *request ) { - static const WCHAR fmtW[] = {'%','s',':',' ','%','s',0}; - static const WCHAR text_plainW[] = {'t','e','x','t','/','p','l','a','i','n',0}; - static const WCHAR charset_utf8W[] = {'c','h','a','r','s','e','t','=','u','t','f','-','8',0}; WCHAR headerW[64]; int len; - len = swprintf( headerW, ARRAY_SIZE(headerW), fmtW, attr_content_type, text_plainW ); + len = swprintf( headerW, ARRAY_SIZE(headerW), L"%s: %s", L"Content-Type", L"text/plain" ); WinHttpAddRequestHeaders( request->hrequest, headerW, len, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW ); - len = swprintf( headerW, ARRAY_SIZE(headerW), fmtW, attr_content_type, charset_utf8W ); + + len = swprintf( headerW, ARRAY_SIZE(headerW), L"%s: %s", L"Content-Type", L"charset=utf-8" ); WinHttpAddRequestHeaders( request->hrequest, headerW, len, WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON ); } @@ -3936,7 +3845,7 @@ static HRESULT request_send( struct winhttp_request *request ) DWORD err; if ((err = request_set_parameters( request ))) return HRESULT_FROM_WIN32( err ); - if (wcscmp( request->verb, getW )) + if (wcscmp( request->verb, L"GET" )) { VariantInit( &data ); if (V_VT( &request->data ) == VT_BSTR) @@ -4139,8 +4048,6 @@ done: static DWORD request_get_codepage( struct winhttp_request *request, UINT *codepage ) { - static const WCHAR utf8W[] = {'u','t','f','-','8',0}; - static const WCHAR charsetW[] = {'c','h','a','r','s','e','t',0}; WCHAR *buffer, *p; DWORD size; @@ -4153,14 +4060,14 @@ static DWORD request_get_codepage( struct winhttp_request *request, UINT *codepa { return GetLastError(); } - if ((p = wcsstr( buffer, charsetW ))) + if ((p = wcsstr( buffer, L"charset" ))) { - p += lstrlenW( charsetW ); + p += lstrlenW( L"charset" ); while (*p == ' ') p++; if (*p++ == '=') { while (*p == ' ') p++; - if (!wcsicmp( p, utf8W )) *codepage = CP_UTF8; + if (!wcsicmp( p, L"utf-8" )) *codepage = CP_UTF8; } } heap_free( buffer ); @@ -4496,9 +4403,7 @@ static HRESULT WINAPI winhttp_request_put_Option( } case WinHttpRequestOption_URLCodePage: { - static const WCHAR utf8W[] = {'u','t','f','-','8',0}; VARIANT cp; - VariantInit( &cp ); hr = VariantChangeType( &cp, &value, 0, VT_UI4 ); if (SUCCEEDED( hr )) @@ -4506,7 +4411,7 @@ static HRESULT WINAPI winhttp_request_put_Option( request->url_codepage = V_UI4( &cp ); TRACE("URL codepage: %u\n", request->url_codepage); } - else if (V_VT( &value ) == VT_BSTR && !wcsicmp( V_BSTR( &value ), utf8W )) + else if (V_VT( &value ) == VT_BSTR && !wcsicmp( V_BSTR( &value ), L"utf-8" )) { TRACE("URL codepage: UTF-8\n"); request->url_codepage = CP_UTF8; diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c index 690b42ab568..3f8acf0e02e 100644 --- a/dlls/winhttp/session.c +++ b/dlls/winhttp/session.c @@ -374,10 +374,9 @@ static const struct object_vtbl connect_vtbl = static BOOL domain_matches(LPCWSTR server, LPCWSTR domain) { - static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 }; BOOL ret = FALSE; - if (!wcsicmp( domain, localW ) && !wcschr( server, '.' )) + if (!wcsicmp( domain, L"" ) && !wcschr( server, '.' )) ret = TRUE; else if (*domain == '*') { @@ -1059,13 +1058,12 @@ static const struct object_vtbl request_vtbl = static BOOL add_accept_types_header( struct request *request, const WCHAR **types ) { - static const WCHAR acceptW[] = {'A','c','c','e','p','t',0}; static const DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA; if (!types) return TRUE; while (*types) { - if (!process_header( request, acceptW, *types, flags, TRUE )) return FALSE; + if (!process_header( request, L"Accept", *types, flags, TRUE )) return FALSE; types++; } return TRUE; @@ -1141,11 +1139,11 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o request->receive_timeout = connect->session->receive_timeout; request->receive_response_timeout = connect->session->receive_response_timeout; - if (!verb || !verb[0]) verb = getW; + if (!verb || !verb[0]) verb = L"GET"; if (!(request->verb = strdupW( verb ))) goto end; if (!(request->path = get_request_path( object ))) goto end; - if (!version || !version[0]) version = http1_1; + if (!version || !version[0]) version = L"HTTP/1.1"; if (!(request->version = strdupW( version ))) goto end; if (!(add_accept_types_header( request, types ))) goto end; @@ -1408,8 +1406,6 @@ static int reverse_lookup( const struct addrinfo *ai, char *hostname, size_t len static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai ) { - static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0}; - static const WCHAR wpadW[] = {'/','w','p','a','d','.','d','a','t',0}; char name[NI_MAXHOST]; WCHAR *ret, *p; int len; @@ -1419,12 +1415,12 @@ static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai ) if (!reverse_lookup( ai, name, sizeof(name) )) hostname = name; - len = lstrlenW( httpW ) + strlen( hostname ) + lstrlenW( wpadW ); + len = lstrlenW( L"http://" ) + strlen( hostname ) + lstrlenW( L"/wpad.dat" ); if (!(ret = p = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) return NULL; - lstrcpyW( p, httpW ); - p += lstrlenW( httpW ); + lstrcpyW( p, L"http://" ); + p += lstrlenW( L"http://" ); while (*hostname) { *p++ = *hostname++; } - lstrcpyW( p, wpadW ); + lstrcpyW( p, L"/wpad.dat" ); return ret; } @@ -1504,15 +1500,9 @@ BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url ) return TRUE; } -static const WCHAR Connections[] = { - 'S','o','f','t','w','a','r','e','\\', - 'M','i','c','r','o','s','o','f','t','\\', - 'W','i','n','d','o','w','s','\\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', - 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\', - 'C','o','n','n','e','c','t','i','o','n','s',0 }; -static const WCHAR WinHttpSettings[] = { - 'W','i','n','H','t','t','p','S','e','t','t','i','n','g','s',0 }; +static const WCHAR path_connections[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections"; + static const DWORD WINHTTP_SETTINGS_MAGIC = 0x18; static const DWORD WININET_SETTINGS_MAGIC = 0x46; static const DWORD PROXY_TYPE_DIRECT = 1; @@ -1548,12 +1538,12 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info ) TRACE("%p\n", info); - l = RegOpenKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, KEY_READ, &key ); + l = RegOpenKeyExW( HKEY_LOCAL_MACHINE, path_connections, 0, KEY_READ, &key ); if (!l) { DWORD type, size = 0; - l = RegQueryValueExW( key, WinHttpSettings, NULL, &type, NULL, &size ); + l = RegQueryValueExW( key, L"WinHttpSettings", NULL, &type, NULL, &size ); if (!l && type == REG_BINARY && size >= sizeof(struct connection_settings_header) + 2 * sizeof(DWORD)) { @@ -1565,7 +1555,7 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info ) (struct connection_settings_header *)buf; DWORD *len = (DWORD *)(hdr + 1); - l = RegQueryValueExW( key, WinHttpSettings, NULL, NULL, buf, + l = RegQueryValueExW( key, L"WinHttpSettings", NULL, NULL, buf, &size ); if (!l && hdr->magic == WINHTTP_SETTINGS_MAGIC && hdr->unknown == 0) @@ -1668,8 +1658,6 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info ) */ BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser( WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *config ) { - static const WCHAR settingsW[] = - {'D','e','f','a','u','l','t','C','o','n','n','e','c','t','i','o','n','S','e','t','t','i','n','g','s',0}; HKEY hkey = NULL; struct connection_settings_header *hdr = NULL; DWORD type, offset, len, size = 0; @@ -1685,15 +1673,15 @@ BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser( WINHTTP_CURRENT_USER_IE_PROXY memset( config, 0, sizeof(*config) ); config->fAutoDetect = TRUE; - if (RegOpenKeyExW( HKEY_CURRENT_USER, Connections, 0, KEY_READ, &hkey ) || - RegQueryValueExW( hkey, settingsW, NULL, &type, NULL, &size ) || + if (RegOpenKeyExW( HKEY_CURRENT_USER, path_connections, 0, KEY_READ, &hkey ) || + RegQueryValueExW( hkey, L"DefaultConnectionSettings", NULL, &type, NULL, &size ) || type != REG_BINARY || size < sizeof(struct connection_settings_header)) { ret = TRUE; goto done; } if (!(hdr = heap_alloc( size ))) goto done; - if (RegQueryValueExW( hkey, settingsW, NULL, &type, (BYTE *)hdr, &size ) || + if (RegQueryValueExW( hkey, L"DefaultConnectionSettings", NULL, &type, (BYTE *)hdr, &size ) || hdr->magic != WININET_SETTINGS_MAGIC) { ret = TRUE; @@ -1782,8 +1770,7 @@ static BOOL parse_script_result( const char *result, WINHTTP_PROXY_INFO *info ) static char *download_script( const WCHAR *url, DWORD *out_size ) { - static const WCHAR typeW[] = {'*','/','*',0}; - static const WCHAR *acceptW[] = {typeW, NULL}; + static const WCHAR *acceptW[] = {L"*/*", NULL}; HINTERNET ses, con = NULL, req = NULL; WCHAR *hostname; URL_COMPONENTSW uc; @@ -1996,7 +1983,7 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info ) return FALSE; } - l = RegCreateKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, NULL, 0, + l = RegCreateKeyExW( HKEY_LOCAL_MACHINE, path_connections, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL ); if (!l) { @@ -2044,7 +2031,7 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info ) *len++ = 0; *len++ = 0; } - l = RegSetValueExW( key, WinHttpSettings, 0, REG_BINARY, buf, size ); + l = RegSetValueExW( key, L"WinHttpSettings", 0, REG_BINARY, buf, size ); if (!l) ret = TRUE; heap_free( buf ); @@ -2150,22 +2137,15 @@ BOOL WINAPI WinHttpSetTimeouts( HINTERNET handle, int resolve, int connect, int } static const WCHAR wkday[7][4] = - {{'S','u','n', 0}, {'M','o','n', 0}, {'T','u','e', 0}, {'W','e','d', 0}, - {'T','h','u', 0}, {'F','r','i', 0}, {'S','a','t', 0}}; + {L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"}; static const WCHAR month[12][4] = - {{'J','a','n', 0}, {'F','e','b', 0}, {'M','a','r', 0}, {'A','p','r', 0}, - {'M','a','y', 0}, {'J','u','n', 0}, {'J','u','l', 0}, {'A','u','g', 0}, - {'S','e','p', 0}, {'O','c','t', 0}, {'N','o','v', 0}, {'D','e','c', 0}}; + {L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"}; /*********************************************************************** * WinHttpTimeFromSystemTime (WININET.@) */ BOOL WINAPI WinHttpTimeFromSystemTime( const SYSTEMTIME *time, LPWSTR string ) { - static const WCHAR format[] = - {'%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0', - '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0}; - TRACE("%p, %p\n", time, string); if (!time || !string) @@ -2174,7 +2154,8 @@ BOOL WINAPI WinHttpTimeFromSystemTime( const SYSTEMTIME *time, LPWSTR string ) return FALSE; } - swprintf( string, WINHTTP_TIME_FORMAT_BUFSIZE / sizeof(WCHAR), format, + swprintf( string, WINHTTP_TIME_FORMAT_BUFSIZE / sizeof(WCHAR), + L"%s, %02d %s %4d %02d:%02d:%02d GMT", wkday[time->wDayOfWeek], time->wDay, month[time->wMonth - 1], diff --git a/dlls/winhttp/url.c b/dlls/winhttp/url.c index d4050904093..ba9ed4366a3 100644 --- a/dlls/winhttp/url.c +++ b/dlls/winhttp/url.c @@ -29,9 +29,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(winhttp); -static const WCHAR scheme_http[] = {'h','t','t','p',0}; -static const WCHAR scheme_https[] = {'h','t','t','p','s',0}; - struct url_component { WCHAR **str; @@ -93,8 +90,7 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len ) static inline BOOL need_escape( WCHAR ch ) { - static const WCHAR escapes[] = {' ','"','#','%','<','>','[','\\',']','^','`','{','|','}','~',0}; - const WCHAR *p = escapes; + const WCHAR *p = L" \"#%<>[\\]^`{|}~"; if (ch <= 31 || ch >= 127) return TRUE; while (*p) @@ -106,7 +102,7 @@ static inline BOOL need_escape( WCHAR ch ) static BOOL escape_string( const WCHAR *src, DWORD src_len, WCHAR *dst, DWORD *dst_len ) { - static const WCHAR hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + static const WCHAR hex[] = L"0123456789ABCDEF"; WCHAR *p = dst; DWORD i; @@ -214,8 +210,8 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN SetLastError( ERROR_WINHTTP_UNRECOGNIZED_SCHEME ); return FALSE; } - if (p - url == 4 && !wcsnicmp( url, scheme_http, 4 )) scheme_number = INTERNET_SCHEME_HTTP; - else if (p - url == 5 && !wcsnicmp( url, scheme_https, 5 )) scheme_number = INTERNET_SCHEME_HTTPS; + if (p - url == 4 && !wcsnicmp( url, L"http", 4 )) scheme_number = INTERNET_SCHEME_HTTP; + else if (p - url == 5 && !wcsnicmp( url, L"https", 5 )) scheme_number = INTERNET_SCHEME_HTTPS; else { err = ERROR_WINHTTP_UNRECOGNIZED_SCHEME; @@ -343,15 +339,15 @@ exit: static INTERNET_SCHEME get_scheme( const WCHAR *scheme, DWORD len ) { - if (!wcsncmp( scheme, scheme_http, len )) return INTERNET_SCHEME_HTTP; - if (!wcsncmp( scheme, scheme_https, len )) return INTERNET_SCHEME_HTTPS; + if (!wcsncmp( scheme, L"http", len )) return INTERNET_SCHEME_HTTP; + if (!wcsncmp( scheme, L"https", len )) return INTERNET_SCHEME_HTTPS; return 0; } static const WCHAR *get_scheme_string( INTERNET_SCHEME scheme ) { - if (scheme == INTERNET_SCHEME_HTTP) return scheme_http; - if (scheme == INTERNET_SCHEME_HTTPS) return scheme_https; + if (scheme == INTERNET_SCHEME_HTTP) return L"http"; + if (scheme == INTERNET_SCHEME_HTTPS) return L"https"; return NULL; } @@ -375,7 +371,6 @@ static DWORD get_comp_length( DWORD len, DWORD flags, WCHAR *comp ) static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len ) { - static const WCHAR formatW[] = {'%','u',0}; INTERNET_SCHEME scheme; *len = 0; @@ -419,7 +414,7 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len ) { WCHAR port[sizeof("65535")]; - *len += swprintf( port, ARRAY_SIZE(port), formatW, uc->nPort ); + *len += swprintf( port, ARRAY_SIZE(port), L"%u", uc->nPort ); *len += 1; /* ":" */ } if (uc->lpszUrlPath && *uc->lpszUrlPath != '/') *len += 1; /* '/' */ @@ -434,7 +429,6 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len ) */ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDWORD required ) { - static const WCHAR formatW[] = {'%','u',0}; DWORD len, len_escaped; INTERNET_SCHEME scheme; @@ -511,7 +505,7 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW if (!uses_default_port( scheme, uc->nPort )) { *url++ = ':'; - url += swprintf( url, sizeof("65535"), formatW, uc->nPort ); + url += swprintf( url, sizeof("65535"), L"%u", uc->nPort ); } /* add slash between hostname and path if necessary */ diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index a820241734f..b3f7092d856 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -26,14 +26,6 @@ #include "sspi.h" #include "wincrypt.h" -static const WCHAR getW[] = {'G','E','T',0}; -static const WCHAR postW[] = {'P','O','S','T',0}; -static const WCHAR headW[] = {'H','E','A','D',0}; -static const WCHAR slashW[] = {'/',0}; -static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0}; -static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0}; -static const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0}; - struct object_header; struct object_vtbl {