Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/wininet/cookie.c | 13 +-
dlls/wininet/dialogs.c | 9 +-
dlls/wininet/ftp.c | 26 ++--
dlls/wininet/http.c | 284 +++++++++++++++-------------------------
dlls/wininet/internet.c | 52 +++-----
dlls/wininet/urlcache.c | 24 +---
6 files changed, 146 insertions(+), 262 deletions(-)
diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c
index 66c012a0db0..6def9ebf9d9 100644
--- a/dlls/wininet/cookie.c
+++ b/dlls/wininet/cookie.c
@@ -392,8 +392,6 @@ static BOOL load_persistent_cookie(substr_t domain, substr_t path)
static BOOL save_persistent_cookie(cookie_container_t *container)
{
- static const WCHAR txtW[] = {'t','x','t',0};
-
WCHAR cookie_file[MAX_PATH];
HANDLE cookie_handle;
cookie_t *cookie_container = NULL, *cookie_iter;
@@ -424,7 +422,7 @@ static BOOL save_persistent_cookie(cookie_container_t *container)
return TRUE;
}
- if(!CreateUrlCacheEntryW(container->cookie_url, 0, txtW, cookie_file, 0))
+ if(!CreateUrlCacheEntryW(container->cookie_url, 0, L"txt", cookie_file, 0))
return FALSE;
cookie_handle = CreateFileW(cookie_file, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
@@ -500,13 +498,12 @@ static BOOL save_persistent_cookie(cookie_container_t *container)
}
memset(&time, 0, sizeof(time));
- return CommitUrlCacheEntryW(container->cookie_url, cookie_file, time, time, 0, NULL, 0, txtW, 0);
+ return CommitUrlCacheEntryW(container->cookie_url, cookie_file, time, time, 0, NULL, 0, L"txt", 0);
}
static BOOL cookie_parse_url(const WCHAR *url, substr_t *host, substr_t *path)
{
URL_COMPONENTSW comp = { sizeof(comp) };
- static const WCHAR rootW[] = {'/',0};
comp.dwHostNameLength = 1;
comp.dwUrlPathLength = 1;
@@ -519,7 +516,7 @@ static BOOL cookie_parse_url(const WCHAR *url, substr_t *host, substr_t *path)
comp.dwUrlPathLength--;
*host = substr(comp.lpszHostName, comp.dwHostNameLength);
- *path = comp.dwUrlPathLength ? substr(comp.lpszUrlPath, comp.dwUrlPathLength) : substr(rootW, 1);
+ *path = comp.dwUrlPathLength ? substr(comp.lpszUrlPath, comp.dwUrlPathLength) : substr(L"/", 1);
return TRUE;
}
@@ -533,8 +530,6 @@ typedef struct {
static DWORD get_cookie(substr_t host, substr_t path, DWORD flags, cookie_set_t *res)
{
- static const WCHAR empty_path[] = { '/',0 };
-
const WCHAR *p;
cookie_domain_t *domain;
cookie_container_t *container;
@@ -549,7 +544,7 @@ static DWORD get_cookie(substr_t host, substr_t path, DWORD flags, cookie_set_t
while(p > host.str && p[-1] != '.') p--;
if(p == host.str) break;
- load_persistent_cookie(substr(p, host.str+host.len-p), substr(empty_path, 1));
+ load_persistent_cookie(substr(p, host.str+host.len-p), substr(L"/", 1));
}
p = path.str + path.len;
diff --git a/dlls/wininet/dialogs.c b/dlls/wininet/dialogs.c
index 29fb10cdf79..a425534fa87 100644
--- a/dlls/wininet/dialogs.c
+++ b/dlls/wininet/dialogs.c
@@ -59,7 +59,6 @@ static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPWSTR szBuf, DWORD sz, BO
{
LPWSTR p, q;
DWORD index, query;
- static const WCHAR szRealm[] = { 'r','e','a','l','m','=',0 };
if (proxy)
query = HTTP_QUERY_PROXY_AUTHENTICATE;
@@ -76,7 +75,7 @@ static BOOL WININET_GetAuthRealm( HINTERNET hRequest, LPWSTR szBuf, DWORD sz, BO
* dealing with 'Basic' Authentication
*/
p = wcschr( szBuf, ' ' );
- if( !p || wcsncmp( p+1, szRealm, lstrlenW(szRealm) ) )
+ if( !p || wcsncmp( p+1, L"realm=", lstrlenW(L"realm=") ) )
{
ERR("response wrong? (%s)\n", debugstr_w(szBuf));
return FALSE;
@@ -112,15 +111,13 @@ static BOOL WININET_GetSetPassword( HWND hdlg, LPCWSTR szServer,
DWORD r, dwMagic = 19;
UINT r_len, u_len;
WORD sz;
- static const WCHAR szColon[] = { ':',0 };
- static const WCHAR szbs[] = { '/', 0 };
hUserItem = GetDlgItem( hdlg, IDC_USERNAME );
hPassItem = GetDlgItem( hdlg, IDC_PASSWORD );
/* now try fetch the username and password */
lstrcpyW( szResource, szServer);
- lstrcatW( szResource, szbs);
+ lstrcatW( szResource, L"/");
lstrcatW( szResource, szRealm);
/*
@@ -133,7 +130,7 @@ static BOOL WININET_GetSetPassword( HWND hdlg, LPCWSTR szServer,
{
szUserPass[0] = 0;
GetWindowTextW( hUserItem, szUserPass, ARRAY_SIZE( szUserPass ) - 1 );
- lstrcatW(szUserPass, szColon);
+ lstrcatW(szUserPass, L":");
u_len = lstrlenW( szUserPass );
GetWindowTextW( hPassItem, szUserPass+u_len, ARRAY_SIZE( szUserPass ) - u_len );
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 09dc1f36fbf..05236972b26 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -159,7 +159,6 @@ static const CHAR *const szFtpCommands[] = {
};
static const CHAR szMonths[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
-static const WCHAR szNoAccount[] = {'n','o','a','c','c','o','u','n','t','\0'};
static BOOL FTP_SendCommand(INT nSocket, FTP_COMMAND ftpCmd, LPCWSTR lpszParam,
INTERNET_STATUS_CALLBACK lpfnStatusCB, object_header_t *hdr, DWORD_PTR dwContext);
@@ -2427,14 +2426,6 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
LPCWSTR lpszPassword, DWORD dwFlags, DWORD_PTR dwContext,
DWORD dwInternalFlags)
{
- static const WCHAR szKey[] = {'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',0};
- static const WCHAR szValue[] = {'E','m','a','i','l','N','a','m','e',0};
- static const WCHAR szDefaultUsername[] = {'a','n','o','n','y','m','o','u','s','\0'};
- static const WCHAR szEmpty[] = {'\0'};
struct sockaddr_in socketAddr;
INT nsocket = -1;
socklen_t sock_namelen;
@@ -2490,14 +2481,14 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
WCHAR szPassword[MAX_PATH];
DWORD len = sizeof(szPassword);
- lpwfs->lpszUserName = heap_strdupW(szDefaultUsername);
+ lpwfs->lpszUserName = heap_strdupW(L"anonymous");
- RegOpenKeyW(HKEY_CURRENT_USER, szKey, &key);
- if (RegQueryValueExW(key, szValue, NULL, NULL, (LPBYTE)szPassword, &len)) {
+ RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", &key);
+ if (RegQueryValueExW(key, L"EmailName", NULL, NULL, (LPBYTE)szPassword, &len)) {
/* Nothing in the registry, get the username and use that as the password */
if (!GetUserNameW(szPassword, &len)) {
/* Should never get here, but use an empty password as failsafe */
- lstrcpyW(szPassword, szEmpty);
+ lstrcpyW(szPassword, L"");
}
}
RegCloseKey(key);
@@ -2507,7 +2498,7 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
}
else {
lpwfs->lpszUserName = heap_strdupW(lpszUserName);
- lpwfs->lpszPassword = heap_strdupW(lpszPassword ? lpszPassword : szEmpty);
+ lpwfs->lpszPassword = heap_strdupW(lpszPassword ? lpszPassword : L"");
}
lpwfs->servername = heap_strdupW(lpszServerName);
@@ -2877,7 +2868,7 @@ static BOOL FTP_SendAccount(ftp_session_t *lpwfs)
BOOL bSuccess = FALSE;
TRACE("\n");
- if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_ACCT, szNoAccount, 0, 0, 0))
+ if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_ACCT, L"noaccount", 0, 0, 0))
goto lend;
nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
@@ -3011,7 +3002,7 @@ lend:
static BOOL FTP_SendType(ftp_session_t *lpwfs, DWORD dwType)
{
INT nResCode;
- WCHAR type[] = { 'I','\0' };
+ WCHAR type[] = L"I";
BOOL bSuccess = FALSE;
TRACE("\n");
@@ -3092,13 +3083,12 @@ lend:
*/
static BOOL FTP_SendPort(ftp_session_t *lpwfs)
{
- static const WCHAR szIPFormat[] = {'%','d',',','%','d',',','%','d',',','%','d',',','%','d',',','%','d','\0'};
INT nResCode;
WCHAR szIPAddress[64];
BOOL bSuccess = FALSE;
TRACE("\n");
- swprintf(szIPAddress, ARRAY_SIZE(szIPAddress), szIPFormat,
+ swprintf(szIPAddress, ARRAY_SIZE(szIPAddress), L"%d,%d,%d,%d,%d,%d",
lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x000000FF,
(lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x0000FF00)>>8,
(lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x00FF0000)>>16,
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 8701e32067b..c770c312ba9 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -60,35 +60,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wininet);
-static const WCHAR g_szHttp1_0[] = {'H','T','T','P','/','1','.','0',0};
-static const WCHAR g_szHttp1_1[] = {'H','T','T','P','/','1','.','1',0};
-static const WCHAR szOK[] = {'O','K',0};
-static const WCHAR hostW[] = { 'H','o','s','t',0 };
-static const WCHAR szAuthorization[] = { 'A','u','t','h','o','r','i','z','a','t','i','o','n',0 };
-static const WCHAR szProxy_Authorization[] = { 'P','r','o','x','y','-','A','u','t','h','o','r','i','z','a','t','i','o','n',0 };
-static const WCHAR szStatus[] = { 'S','t','a','t','u','s',0 };
-static const WCHAR szKeepAlive[] = {'K','e','e','p','-','A','l','i','v','e',0};
-static const WCHAR szGET[] = { 'G','E','T', 0 };
-static const WCHAR szHEAD[] = { 'H','E','A','D', 0 };
-
-static const WCHAR szAccept[] = { 'A','c','c','e','p','t',0 };
-static const WCHAR szCache_Control[] = { 'C','a','c','h','e','-','C','o','n','t','r','o','l',0 };
-static const WCHAR szConnection[] = { 'C','o','n','n','e','c','t','i','o','n',0 };
-static const WCHAR szContent_Encoding[] = { 'C','o','n','t','e','n','t','-','E','n','c','o','d','i','n','g',0 };
-static const WCHAR szContent_Length[] = { 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',0 };
-static const WCHAR szContent_Type[] = { 'C','o','n','t','e','n','t','-','T','y','p','e',0 };
-static const WCHAR szExpires[] = { 'E','x','p','i','r','e','s',0 };
-static const WCHAR szLast_Modified[] = { 'L','a','s','t','-','M','o','d','i','f','i','e','d',0 };
-static const WCHAR szProxy_Connection[] = { 'P','r','o','x','y','-','C','o','n','n','e','c','t','i','o','n',0 };
-static const WCHAR szReferer[] = { 'R','e','f','e','r','e','r',0 };
-static const WCHAR szSet_Cookie[] = { 'S','e','t','-','C','o','o','k','i','e',0 };
-
-static const WCHAR emptyW[] = {0};
-
-#define HTTP_REFERER szReferer
-#define HTTP_ACCEPT szAccept
-#define HTTP_USERAGENT szUser_Agent
-
#define HTTP_ADDHDR_FLAG_ADD 0x20000000
#define HTTP_ADDHDR_FLAG_ADD_IF_NEW 0x10000000
#define HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA 0x40000000
@@ -196,17 +167,13 @@ static BOOL process_host_port(server_t *server)
size_t name_len, len;
WCHAR *buf;
- static const WCHAR httpW[] = {'h','t','t','p',0};
- static const WCHAR httpsW[] = {'h','t','t','p','s',0};
- static const WCHAR formatW[] = {'%','s',':','/','/','%','s',':','%','u',0};
-
name_len = lstrlenW(server->name);
- len = name_len + 10 /* strlen("://:<port>") */ + ARRAY_SIZE(httpsW);
+ len = name_len + 10 /* strlen("://:<port>") */ + ARRAY_SIZE(L"https");
buf = heap_alloc( len * sizeof(WCHAR) );
if(!buf)
return FALSE;
- swprintf(buf, len, formatW, server->is_https ? httpsW : httpW, server->name, server->port);
+ swprintf(buf, len, L"%s://%s:%u", server->is_https ? L"https" : L"http", server->name, server->port);
server->scheme_host_port = buf;
server->host_port = server->scheme_host_port + 7 /* strlen("http://") */;
@@ -326,7 +293,7 @@ static WCHAR *get_host_header( http_request_t *req )
WCHAR *ret = NULL;
EnterCriticalSection( &req->headers_section );
- if ((header = HTTP_GetHeader( req, hostW ))) ret = heap_strdupW( header->lpszValue );
+ if ((header = HTTP_GetHeader( req, L"Host" ))) ret = heap_strdupW( header->lpszValue );
else ret = heap_strdupW( req->server->canon_host_port );
LeaveCriticalSection( &req->headers_section );
return ret;
@@ -514,7 +481,7 @@ static DWORD init_gzip_stream(http_request_t *req, BOOL is_gzip)
return ERROR_OUTOFMEMORY;
}
- remove_header(req, szContent_Length, FALSE);
+ remove_header(req, L"Content-Length", FALSE);
if(req->read_size) {
memcpy(gzip_stream->buf, req->read_buf+req->read_pos, req->read_size);
@@ -542,12 +509,9 @@ static void HTTP_FreeTokens(LPWSTR * token_array)
static void HTTP_FixURL(http_request_t *request)
{
- static const WCHAR szSlash[] = { '/',0 };
- static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/', 0 };
-
/* If we don't have a path we set it to root */
if (NULL == request->path)
- request->path = heap_strdupW(szSlash);
+ request->path = heap_strdupW(L"/");
else /* remove \r and \n*/
{
int nLen = lstrlenW(request->path);
@@ -564,7 +528,7 @@ static void HTTP_FixURL(http_request_t *request)
}
if(CSTR_EQUAL != CompareStringW( LOCALE_INVARIANT, NORM_IGNORECASE,
- request->path, lstrlenW(request->path), szHttp, lstrlenW(szHttp) )
+ request->path, lstrlenW(request->path), L"http://", lstrlenW(L"http://") )
&& request->path[0] != '/') /* not an absolute path ?? --> fix it !! */
{
WCHAR *fixurl = heap_alloc((lstrlenW(request->path) + 2)*sizeof(WCHAR));
@@ -578,10 +542,6 @@ static void HTTP_FixURL(http_request_t *request)
static WCHAR* build_request_header(http_request_t *request, const WCHAR *verb,
const WCHAR *path, const WCHAR *version, BOOL use_cr)
{
- static const WCHAR szSpace[] = {' ',0};
- static const WCHAR szColon[] = {':',' ',0};
- static const WCHAR szCr[] = {'\r',0};
- static const WCHAR szLf[] = {'\n',0};
LPWSTR requestString;
DWORD len, n;
LPCWSTR *req;
@@ -600,13 +560,13 @@ static WCHAR* build_request_header(http_request_t *request, const WCHAR *verb,
/* add the verb, path and HTTP version string */
n = 0;
req[n++] = verb;
- req[n++] = szSpace;
+ req[n++] = L" ";
req[n++] = path;
- req[n++] = szSpace;
+ req[n++] = L" ";
req[n++] = version;
if (use_cr)
- req[n++] = szCr;
- req[n++] = szLf;
+ req[n++] = L"\r";
+ req[n++] = L"\n";
/* Append custom request headers */
for (i = 0; i < request->nCustHeaders; i++)
@@ -614,11 +574,11 @@ static WCHAR* build_request_header(http_request_t *request, const WCHAR *verb,
if (request->custHeaders[i].wFlags & HDR_ISREQUEST)
{
req[n++] = request->custHeaders[i].lpszField;
- req[n++] = szColon;
+ req[n++] = L": ";
req[n++] = request->custHeaders[i].lpszValue;
if (use_cr)
- req[n++] = szCr;
- req[n++] = szLf;
+ req[n++] = L"\r";
+ req[n++] = L"\n";
TRACE("Adding custom header %s (%s)\n",
debugstr_w(request->custHeaders[i].lpszField),
@@ -626,8 +586,8 @@ static WCHAR* build_request_header(http_request_t *request, const WCHAR *verb,
}
}
if (use_cr)
- req[n++] = szCr;
- req[n++] = szLf;
+ req[n++] = L"\r";
+ req[n++] = L"\n";
req[n] = NULL;
requestString = HTTP_build_req( req, 4 );
@@ -638,10 +598,6 @@ static WCHAR* build_request_header(http_request_t *request, const WCHAR *verb,
static WCHAR* build_response_header(http_request_t *request, BOOL use_cr)
{
- static const WCHAR colonW[] = { ':',' ',0 };
- static const WCHAR crW[] = { '\r',0 };
- static const WCHAR lfW[] = { '\n',0 };
- static const WCHAR status_fmt[] = { ' ','%','u',' ',0 };
const WCHAR **req;
WCHAR *ret, buf[14];
DWORD i, n = 0;
@@ -657,25 +613,25 @@ static WCHAR* build_response_header(http_request_t *request, BOOL use_cr)
if (request->status_code)
{
req[n++] = request->version;
- swprintf(buf, ARRAY_SIZE(buf), status_fmt, request->status_code);
+ swprintf(buf, ARRAY_SIZE(buf), L" %u ", request->status_code);
req[n++] = buf;
req[n++] = request->statusText;
if (use_cr)
- req[n++] = crW;
- req[n++] = lfW;
+ req[n++] = L"\r";
+ req[n++] = L"\n";
}
for(i = 0; i < request->nCustHeaders; i++)
{
if(!(request->custHeaders[i].wFlags & HDR_ISREQUEST)
- && wcscmp(request->custHeaders[i].lpszField, szStatus))
+ && wcscmp(request->custHeaders[i].lpszField, L"Status"))
{
req[n++] = request->custHeaders[i].lpszField;
- req[n++] = colonW;
+ req[n++] = L": ";
req[n++] = request->custHeaders[i].lpszValue;
if(use_cr)
- req[n++] = crW;
- req[n++] = lfW;
+ req[n++] = L"\r";
+ req[n++] = L"\n";
TRACE("Adding custom header %s (%s)\n",
debugstr_w(request->custHeaders[i].lpszField),
@@ -683,8 +639,8 @@ static WCHAR* build_response_header(http_request_t *request, BOOL use_cr)
}
}
if(use_cr)
- req[n++] = crW;
- req[n++] = lfW;
+ req[n++] = L"\r";
+ req[n++] = L"\n";
req[n] = NULL;
ret = HTTP_build_req(req, 0);
@@ -704,7 +660,7 @@ static void HTTP_ProcessCookies( http_request_t *request )
EnterCriticalSection( &request->headers_section );
- while((HeaderIndex = HTTP_GetCustomHeaderIndex(request, szSet_Cookie, numCookies++, FALSE)) != -1)
+ while((HeaderIndex = HTTP_GetCustomHeaderIndex(request, L"Set-Cookie", numCookies++, FALSE)) != -1)
{
const WCHAR *data;
substr_t name;
@@ -1023,8 +979,7 @@ static BOOL HTTP_DoAuthorization( http_request_t *request, LPCWSTR pszAuthValue,
if (is_basic_auth_value(pszAuthValue,NULL))
{
- static const WCHAR szBasic[] = {'B','a','s','i','c',0};
- pAuthInfo->scheme = heap_strdupW(szBasic);
+ pAuthInfo->scheme = heap_strdupW(L"Basic");
if (!pAuthInfo->scheme)
{
heap_free(pAuthInfo);
@@ -1615,7 +1570,6 @@ static WCHAR *encode_auth_data( const WCHAR *scheme, const char *data, UINT data
*/
static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthInfo *pAuthInfo, LPCWSTR header )
{
- static const WCHAR wszBasic[] = {'B','a','s','i','c',0};
WCHAR *host, *authorization = NULL;
if (pAuthInfo)
@@ -1628,7 +1582,7 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn
/* clear the data as it isn't valid now that it has been sent to the
* server, unless it's Basic authentication which doesn't do
* connection tracking */
- if (wcsicmp(pAuthInfo->scheme, wszBasic))
+ if (wcsicmp(pAuthInfo->scheme, L"Basic"))
{
heap_free(pAuthInfo->auth_data);
pAuthInfo->auth_data = NULL;
@@ -1648,7 +1602,7 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn
char *data;
/* Don't use cached credentials when a username or Authorization was specified */
- if ((request->session->userName && request->session->userName[0]) || wcscmp(header, szAuthorization))
+ if ((request->session->userName && request->session->userName[0]) || wcscmp(header, L"Authorization"))
return TRUE;
if (!(host = get_host_header(request)))
@@ -1658,7 +1612,7 @@ static BOOL HTTP_InsertAuthorization( http_request_t *request, struct HttpAuthIn
{
TRACE("Found cached basic authorization for %s\n", debugstr_w(host));
- if (!(authorization = encode_auth_data(wszBasic, data, data_len)))
+ if (!(authorization = encode_auth_data(L"Basic", data, data_len)))
{
heap_free(data);
heap_free(host);
@@ -1702,11 +1656,10 @@ static WCHAR *build_proxy_path_url(http_request_t *req)
static BOOL HTTP_DomainMatches(LPCWSTR server, substr_t domain)
{
- static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
const WCHAR *dot, *ptr;
int len;
- if(domain.len == ARRAY_SIZE(localW)-1 && !wcsnicmp(domain.str, localW, domain.len) && !wcschr(server, '.' ))
+ if(domain.len == ARRAY_SIZE(L"<local>")-1 && !wcsnicmp(domain.str, L"<local>", domain.len) && !wcschr(server, '.' ))
return TRUE;
if(domain.len && *domain.str != '*')
@@ -1771,24 +1724,22 @@ static BOOL HTTP_ShouldBypassProxy(appinfo_t *lpwai, LPCWSTR server)
*/
static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_request_t *request)
{
- static const WCHAR protoHttp[] = { 'h','t','t','p',0 };
- static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/',0 };
- static WCHAR szNul[] = { 0 };
+ static WCHAR szNul[] = L"";
URL_COMPONENTSW UrlComponents = { sizeof(UrlComponents) };
server_t *new_server = NULL;
WCHAR *proxy;
- proxy = INTERNET_FindProxyForProtocol(hIC->proxy, protoHttp);
+ proxy = INTERNET_FindProxyForProtocol(hIC->proxy, L"http");
if(!proxy)
return FALSE;
if(CSTR_EQUAL != CompareStringW(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE,
- proxy, lstrlenW(szHttp), szHttp, lstrlenW(szHttp))) {
- WCHAR *proxy_url = heap_alloc(lstrlenW(proxy)*sizeof(WCHAR) + sizeof(szHttp));
+ proxy, lstrlenW(L"http://"), L"http://", lstrlenW(L"http://"))) {
+ WCHAR *proxy_url = heap_alloc(lstrlenW(proxy)*sizeof(WCHAR) + sizeof(L"http://"));
if(!proxy_url) {
heap_free(proxy);
return FALSE;
}
- lstrcpyW(proxy_url, szHttp);
+ lstrcpyW(proxy_url, L"http://");
lstrcatW(proxy_url, proxy);
heap_free(proxy);
proxy = proxy_url;
@@ -1840,8 +1791,6 @@ static DWORD HTTP_ResolveName(http_request_t *request)
static WCHAR *compose_request_url(http_request_t *req)
{
- static const WCHAR http[] = { 'h','t','t','p',':','/','/',0 };
- static const WCHAR https[] = { 'h','t','t','p','s',':','/','/',0 };
const WCHAR *host, *scheme;
WCHAR *buf, *ptr;
size_t len;
@@ -1849,9 +1798,9 @@ static WCHAR *compose_request_url(http_request_t *req)
host = req->server->canon_host_port;
if (req->server->is_https)
- scheme = https;
+ scheme = L"https://";
else
- scheme = http;
+ scheme = L"http://";
len = lstrlenW(scheme) + lstrlenW(host) + (req->path[0] != '/' ? 1 : 0) + lstrlenW(req->path);
ptr = buf = heap_alloc((len+1) * sizeof(WCHAR));
@@ -1981,7 +1930,7 @@ static BOOL HTTP_KeepAlive(http_request_t *request)
/* as per RFC 2068, S8.1.2.1, if the client is HTTP/1.1 then assume that
* the connection is keep-alive by default */
if (HTTP_HttpQueryInfoW(request, HTTP_QUERY_VERSION, szVersion, &dwBufferSize, NULL) == ERROR_SUCCESS
- && !wcsicmp(szVersion, g_szHttp1_1))
+ && !wcsicmp(szVersion, L"HTTP/1.1"))
{
keepalive = TRUE;
}
@@ -1990,7 +1939,7 @@ static BOOL HTTP_KeepAlive(http_request_t *request)
if (HTTP_HttpQueryInfoW(request, HTTP_QUERY_PROXY_CONNECTION, szConnectionResponse, &dwBufferSize, NULL) == ERROR_SUCCESS
|| HTTP_HttpQueryInfoW(request, HTTP_QUERY_CONNECTION, szConnectionResponse, &dwBufferSize, NULL) == ERROR_SUCCESS)
{
- keepalive = !wcsicmp(szConnectionResponse, szKeepAlive);
+ keepalive = !wcsicmp(szConnectionResponse, L"Keep-Alive");
}
return keepalive;
@@ -2471,9 +2420,6 @@ static void commit_cache_entry(http_request_t *req)
static void create_cache_entry(http_request_t *req)
{
- static const WCHAR no_cacheW[] = {'n','o','-','c','a','c','h','e',0};
- static const WCHAR no_storeW[] = {'n','o','-','s','t','o','r','e',0};
-
WCHAR file_name[MAX_PATH+1];
WCHAR *url;
BOOL b = TRUE;
@@ -2496,7 +2442,7 @@ static void create_cache_entry(http_request_t *req)
EnterCriticalSection( &req->headers_section );
- header_idx = HTTP_GetCustomHeaderIndex(req, szCache_Control, 0, FALSE);
+ header_idx = HTTP_GetCustomHeaderIndex(req, L"Cache-Control", 0, FALSE);
if(header_idx != -1) {
WCHAR *ptr;
@@ -2510,8 +2456,8 @@ static void create_cache_entry(http_request_t *req)
if(!end)
end = ptr + lstrlenW(ptr);
- if(!wcsnicmp(ptr, no_cacheW, ARRAY_SIZE(no_cacheW)-1)
- || !wcsnicmp(ptr, no_storeW, ARRAY_SIZE(no_storeW)-1)) {
+ if(!wcsnicmp(ptr, L"no-cache", ARRAY_SIZE(L"no-cache")-1)
+ || !wcsnicmp(ptr, L"no-store", ARRAY_SIZE(L"no-store")-1)) {
b = FALSE;
break;
}
@@ -2968,13 +2914,11 @@ static const data_stream_vtbl_t chunked_stream_vtbl = {
/* set the request content length based on the headers */
static DWORD set_content_length(http_request_t *request)
{
- static const WCHAR szChunked[] = {'c','h','u','n','k','e','d',0};
- static const WCHAR headW[] = {'H','E','A','D',0};
WCHAR contentLength[32];
WCHAR encoding[20];
DWORD size;
- if(request->status_code == HTTP_STATUS_NO_CONTENT || !wcscmp(request->verb, headW)) {
+ if(request->status_code == HTTP_STATUS_NO_CONTENT || !wcscmp(request->verb, L"HEAD")) {
request->contentLength = request->netconn_stream.content_length = 0;
return ERROR_SUCCESS;
}
@@ -2991,7 +2935,7 @@ static DWORD set_content_length(http_request_t *request)
size = sizeof(encoding);
if (HTTP_HttpQueryInfoW(request, HTTP_QUERY_TRANSFER_ENCODING, encoding, &size, NULL) == ERROR_SUCCESS &&
- !wcsicmp(encoding, szChunked))
+ !wcsicmp(encoding, L"chunked"))
{
chunked_stream_t *chunked_stream;
@@ -3017,19 +2961,16 @@ static DWORD set_content_length(http_request_t *request)
if(request->hdr.decoding) {
int encoding_idx;
- static const WCHAR deflateW[] = {'d','e','f','l','a','t','e',0};
- static const WCHAR gzipW[] = {'g','z','i','p',0};
-
EnterCriticalSection( &request->headers_section );
- encoding_idx = HTTP_GetCustomHeaderIndex(request, szContent_Encoding, 0, FALSE);
+ encoding_idx = HTTP_GetCustomHeaderIndex(request, L"Content-Encoding", 0, FALSE);
if(encoding_idx != -1) {
- if(!wcsicmp(request->custHeaders[encoding_idx].lpszValue, gzipW)) {
+ if(!wcsicmp(request->custHeaders[encoding_idx].lpszValue, L"gzip")) {
HTTP_DeleteCustomHeader(request, encoding_idx);
LeaveCriticalSection( &request->headers_section );
return init_gzip_stream(request, TRUE);
}
- if(!wcsicmp(request->custHeaders[encoding_idx].lpszValue, deflateW)) {
+ if(!wcsicmp(request->custHeaders[encoding_idx].lpszValue, L"deflate")) {
HTTP_DeleteCustomHeader(request, encoding_idx);
LeaveCriticalSection( &request->headers_section );
return init_gzip_stream(request, FALSE);
@@ -3128,7 +3069,7 @@ static DWORD drain_content(http_request_t *req, BOOL blocking)
if(!is_valid_netconn(req->netconn))
return ERROR_NO_DATA;
- if(!wcscmp(req->verb, szHEAD))
+ if(!wcscmp(req->verb, L"HEAD"))
return ERROR_SUCCESS;
EnterCriticalSection( &req->read_section );
@@ -3452,13 +3393,11 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
lstrcpyW(request->path,lpszObjectName);
}
}else {
- static const WCHAR slashW[] = {'/',0};
-
- request->path = heap_strdupW(slashW);
+ request->path = heap_strdupW(L"/");
}
if (lpszReferrer && *lpszReferrer)
- HTTP_ProcessHeader(request, HTTP_REFERER, lpszReferrer, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
+ HTTP_ProcessHeader(request, L"Referer", lpszReferrer, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ);
if (lpszAcceptTypes)
{
@@ -3466,15 +3405,15 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
for (i = 0; lpszAcceptTypes[i]; i++)
{
if (!*lpszAcceptTypes[i]) continue;
- HTTP_ProcessHeader(request, HTTP_ACCEPT, lpszAcceptTypes[i],
+ HTTP_ProcessHeader(request, L"Accept", lpszAcceptTypes[i],
HTTP_ADDHDR_FLAG_COALESCE_WITH_COMMA |
HTTP_ADDHDR_FLAG_REQ |
(i == 0 ? (HTTP_ADDHDR_FLAG_REPLACE | HTTP_ADDHDR_FLAG_ADD) : 0));
}
}
- request->verb = heap_strdupW(lpszVerb && *lpszVerb ? lpszVerb : szGET);
- request->version = heap_strdupW(lpszVersion && *lpszVersion ? lpszVersion : g_szHttp1_1);
+ request->verb = heap_strdupW(lpszVerb && *lpszVerb ? lpszVerb : L"GET");
+ request->version = heap_strdupW(lpszVersion && *lpszVersion ? lpszVersion : L"HTTP/1.1");
if (hIC->proxy && hIC->proxy[0] && !HTTP_ShouldBypassProxy(hIC, session->hostName))
HTTP_DealWithProxy( hIC, session, request );
@@ -3787,9 +3726,8 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
}else {
WCHAR buf[12];
DWORD size;
- static const WCHAR formatW[] = {'%','u',0};
- size = swprintf(buf, ARRAY_SIZE(buf), formatW, request->status_code) * sizeof(WCHAR);
+ size = swprintf(buf, ARRAY_SIZE(buf), L"%u", request->status_code) * sizeof(WCHAR);
if(size <= *lpdwBufferLength) {
memcpy(lpBuffer, buf, size+sizeof(WCHAR));
@@ -4109,8 +4047,8 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
static WCHAR *get_redirect_url(http_request_t *request)
{
- static WCHAR szHttp[] = {'h','t','t','p',0};
- static WCHAR szHttps[] = {'h','t','t','p','s',0};
+ static WCHAR szHttp[] = L"http";
+ static WCHAR szHttps[] = L"https";
http_session_t *session = request->session;
URL_COMPONENTSW urlComponents = { sizeof(urlComponents) };
WCHAR *orig_url = NULL, *redirect_url = NULL, *combined_url = NULL;
@@ -4247,9 +4185,11 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url)
}
if (custom_port)
- HTTP_ProcessHeader(request, hostW, request->server->host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
+ HTTP_ProcessHeader(request, L"Host", request->server->host_port,
+ HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
else
- HTTP_ProcessHeader(request, hostW, request->server->name, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
+ HTTP_ProcessHeader(request, L"Host", request->server->name,
+ HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ);
}
heap_free(request->path);
@@ -4258,11 +4198,11 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url)
{
DWORD needed = 1;
HRESULT rc;
- WCHAR dummy = 0;
+ WCHAR dummy[] = L"";
WCHAR *path;
path = heap_strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength);
- rc = UrlEscapeW(path, &dummy, &needed, URL_ESCAPE_SPACES_ONLY);
+ rc = UrlEscapeW(path, dummy, &needed, URL_ESCAPE_SPACES_ONLY);
if (rc != E_POINTER)
ERR("Unable to escape string!(%s) (%d)\n",debugstr_w(path),rc);
request->path = heap_alloc(needed*sizeof(WCHAR));
@@ -4277,8 +4217,8 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url)
}
/* Remove custom content-type/length headers on redirects. */
- remove_header(request, szContent_Type, TRUE);
- remove_header(request, szContent_Length, TRUE);
+ remove_header(request, L"Content-Type", TRUE);
+ remove_header(request, L"Content-Length", TRUE);
return ERROR_SUCCESS;
}
@@ -4414,7 +4354,6 @@ static BOOL HTTP_ParseTime(SYSTEMTIME *st, LPCWSTR *str)
static BOOL HTTP_ParseDateAsAsctime(LPCWSTR value, FILETIME *ft)
{
- static const WCHAR gmt[]= { 'G','M','T',0 };
WCHAR day[4], *dayPtr, month[4], *monthPtr, *nextPtr;
LPCWSTR ptr;
SYSTEMTIME st = { 0 };
@@ -4481,7 +4420,7 @@ static BOOL HTTP_ParseDateAsAsctime(LPCWSTR value, FILETIME *ft)
/* asctime() doesn't report a timezone, but some web servers do, so accept
* with or without GMT.
*/
- if (*ptr && wcscmp(ptr, gmt))
+ if (*ptr && wcscmp(ptr, L"GMT"))
{
ERR("unexpected timezone %s\n", debugstr_w(ptr));
return FALSE;
@@ -4491,7 +4430,6 @@ static BOOL HTTP_ParseDateAsAsctime(LPCWSTR value, FILETIME *ft)
static BOOL HTTP_ParseRfc1123Date(LPCWSTR value, FILETIME *ft)
{
- static const WCHAR gmt[]= { 'G','M','T',0 };
WCHAR *nextPtr, day[4], month[4], *monthPtr;
LPCWSTR ptr;
unsigned long num;
@@ -4559,7 +4497,7 @@ static BOOL HTTP_ParseRfc1123Date(LPCWSTR value, FILETIME *ft)
while (iswspace(*ptr))
ptr++;
- if (wcscmp(ptr, gmt))
+ if (wcscmp(ptr, L"GMT"))
{
ERR("unexpected time zone %s\n", debugstr_w(ptr));
return FALSE;
@@ -4587,7 +4525,6 @@ static WORD HTTP_ParseWeekday(LPCWSTR day)
static BOOL HTTP_ParseRfc850Date(LPCWSTR value, FILETIME *ft)
{
- static const WCHAR gmt[]= { 'G','M','T',0 };
WCHAR *nextPtr, day[10], month[4], *monthPtr;
LPCWSTR ptr;
unsigned long num;
@@ -4677,7 +4614,7 @@ static BOOL HTTP_ParseRfc850Date(LPCWSTR value, FILETIME *ft)
while (iswspace(*ptr))
ptr++;
- if (wcscmp(ptr, gmt))
+ if (wcscmp(ptr, L"GMT"))
{
ERR("unexpected time zone %s\n", debugstr_w(ptr));
return FALSE;
@@ -4687,10 +4624,9 @@ static BOOL HTTP_ParseRfc850Date(LPCWSTR value, FILETIME *ft)
static BOOL HTTP_ParseDate(LPCWSTR value, FILETIME *ft)
{
- static const WCHAR zero[] = { '0',0 };
BOOL ret;
- if (!wcscmp(value, zero))
+ if (!wcscmp(value, L"0"))
{
ft->dwLowDateTime = ft->dwHighDateTime = 0;
ret = TRUE;
@@ -4724,7 +4660,7 @@ static void HTTP_ProcessExpires(http_request_t *request)
/* Look for a Cache-Control header with a max-age directive, as it takes
* precedence over the Expires header.
*/
- headerIndex = HTTP_GetCustomHeaderIndex(request, szCache_Control, 0, FALSE);
+ headerIndex = HTTP_GetCustomHeaderIndex(request, L"Cache-Control", 0, FALSE);
if (headerIndex != -1)
{
LPHTTPHEADERW ccHeader = &request->custHeaders[headerIndex];
@@ -4742,10 +4678,7 @@ static void HTTP_ProcessExpires(http_request_t *request)
;
if (*equal == '=')
{
- static const WCHAR max_age[] = {
- 'm','a','x','-','a','g','e',0 };
-
- if (!wcsnicmp(ptr, max_age, equal - ptr - 1))
+ if (!wcsnicmp(ptr, L"max-age", equal - ptr - 1))
{
LPWSTR nextPtr;
unsigned long age;
@@ -4778,7 +4711,7 @@ static void HTTP_ProcessExpires(http_request_t *request)
}
if (!expirationFound)
{
- headerIndex = HTTP_GetCustomHeaderIndex(request, szExpires, 0, FALSE);
+ headerIndex = HTTP_GetCustomHeaderIndex(request, L"Expires", 0, FALSE);
if (headerIndex != -1)
{
LPHTTPHEADERW expiresHeader = &request->custHeaders[headerIndex];
@@ -4811,7 +4744,7 @@ static void HTTP_ProcessLastModified(http_request_t *request)
EnterCriticalSection( &request->headers_section );
- headerIndex = HTTP_GetCustomHeaderIndex(request, szLast_Modified, 0, FALSE);
+ headerIndex = HTTP_GetCustomHeaderIndex(request, L"Last-Modified", 0, FALSE);
if (headerIndex != -1)
{
LPHTTPHEADERW expiresHeader = &request->custHeaders[headerIndex];
@@ -4830,12 +4763,12 @@ static void http_process_keep_alive(http_request_t *req)
EnterCriticalSection( &req->headers_section );
- if ((index = HTTP_GetCustomHeaderIndex(req, szConnection, 0, FALSE)) != -1)
- req->netconn->keep_alive = !wcsicmp(req->custHeaders[index].lpszValue, szKeepAlive);
- else if ((index = HTTP_GetCustomHeaderIndex(req, szProxy_Connection, 0, FALSE)) != -1)
- req->netconn->keep_alive = !wcsicmp(req->custHeaders[index].lpszValue, szKeepAlive);
+ if ((index = HTTP_GetCustomHeaderIndex(req, L"Connection", 0, FALSE)) != -1)
+ req->netconn->keep_alive = !wcsicmp(req->custHeaders[index].lpszValue, L"Keep-Alive");
+ else if ((index = HTTP_GetCustomHeaderIndex(req, L"Proxy-Connection", 0, FALSE)) != -1)
+ req->netconn->keep_alive = !wcsicmp(req->custHeaders[index].lpszValue, L"Keep-Alive");
else
- req->netconn->keep_alive = !wcsicmp(req->version, g_szHttp1_1);
+ req->netconn->keep_alive = !wcsicmp(req->version, L"HTTP/1.1");
LeaveCriticalSection( &req->headers_section );
}
@@ -4930,11 +4863,9 @@ static char *build_ascii_request( const WCHAR *str, void *data, DWORD data_len,
static void set_content_length_header( http_request_t *request, DWORD len, DWORD flags )
{
- static const WCHAR fmtW[] =
- {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
- WCHAR buf[ARRAY_SIZE(fmtW) + 10];
+ WCHAR buf[ARRAY_SIZE(L"Content-Length: %u\r\n") + 10];
- swprintf( buf, ARRAY_SIZE(buf), fmtW, len );
+ swprintf( buf, ARRAY_SIZE(buf), L"Content-Length: %u\r\n", len );
HTTP_HttpAddRequestHeadersW( request, buf, ~0u, flags );
}
@@ -4963,12 +4894,12 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
/* if the verb is NULL default to GET */
if (!request->verb)
- request->verb = heap_strdupW(szGET);
+ request->verb = heap_strdupW(L"GET");
- HTTP_ProcessHeader(request, hostW, request->server->canon_host_port,
+ HTTP_ProcessHeader(request, L"Host", request->server->canon_host_port,
HTTP_ADDREQ_FLAG_ADD_IF_NEW | HTTP_ADDHDR_FLAG_REQ);
- if (dwContentLength || wcscmp(request->verb, szGET))
+ if (dwContentLength || wcscmp(request->verb, L"GET"))
{
set_content_length_header(request, dwContentLength, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
request->bytesToWrite = dwContentLength;
@@ -4976,26 +4907,24 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
if (request->session->appInfo->agent)
{
WCHAR *agent_header;
- static const WCHAR user_agent[] = {'U','s','e','r','-','A','g','e','n','t',':',' ','%','s','\r','\n',0};
int len;
- len = lstrlenW(request->session->appInfo->agent) + lstrlenW(user_agent);
+ len = lstrlenW(request->session->appInfo->agent) + lstrlenW(L"User-Agent: %s\r\n");
agent_header = heap_alloc(len * sizeof(WCHAR));
- swprintf(agent_header, len, user_agent, request->session->appInfo->agent);
+ swprintf(agent_header, len, L"User-Agent: %s\r\n", request->session->appInfo->agent);
HTTP_HttpAddRequestHeadersW(request, agent_header, lstrlenW(agent_header), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
heap_free(agent_header);
}
if (request->hdr.dwFlags & INTERNET_FLAG_PRAGMA_NOCACHE)
{
- static const WCHAR pragma_nocache[] = {'P','r','a','g','m','a',':',' ','n','o','-','c','a','c','h','e','\r','\n',0};
- HTTP_HttpAddRequestHeadersW(request, pragma_nocache, lstrlenW(pragma_nocache), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ HTTP_HttpAddRequestHeadersW(request, L"Pragma: no-cache\r\n",
+ lstrlenW(L"Pragma: no-cache\r\n"), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
}
- if ((request->hdr.dwFlags & INTERNET_FLAG_NO_CACHE_WRITE) && wcscmp(request->verb, szGET))
+ if ((request->hdr.dwFlags & INTERNET_FLAG_NO_CACHE_WRITE) && wcscmp(request->verb, L"GET"))
{
- static const WCHAR cache_control[] = {'C','a','c','h','e','-','C','o','n','t','r','o','l',':',
- ' ','n','o','-','c','a','c','h','e','\r','\n',0};
- HTTP_HttpAddRequestHeadersW(request, cache_control, lstrlenW(cache_control), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
+ HTTP_HttpAddRequestHeadersW(request, L"Cache-Control: no-cache\r\n",
+ lstrlenW(L"Cache-Control: no-cache\r\n"), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
}
/* add the headers the caller supplied */
@@ -5020,7 +4949,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
HTTPHEADERW *host;
EnterCriticalSection( &request->headers_section );
- host = HTTP_GetHeader( request, hostW );
+ host = HTTP_GetHeader(request, L"Host");
TRACE("Going to url %s %s\n", debugstr_w(host->lpszValue), debugstr_w(request->path));
LeaveCriticalSection( &request->headers_section );
}
@@ -5028,11 +4957,11 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
HTTP_FixURL(request);
if (request->hdr.dwFlags & INTERNET_FLAG_KEEP_CONNECTION)
{
- HTTP_ProcessHeader(request, szConnection, szKeepAlive,
+ HTTP_ProcessHeader(request, L"Connection", L"Keep-Alive",
HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_REPLACE | HTTP_ADDHDR_FLAG_ADD);
}
- HTTP_InsertAuthorization(request, request->authInfo, szAuthorization);
- HTTP_InsertAuthorization(request, request->proxyAuthInfo, szProxy_Authorization);
+ HTTP_InsertAuthorization(request, request->authInfo, L"Authorization");
+ HTTP_InsertAuthorization(request, request->proxyAuthInfo, L"Proxy-Authorization");
if (!(request->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES))
HTTP_InsertCookies(request);
@@ -5057,13 +4986,12 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
}
if (secure_proxy_connect)
{
- static const WCHAR connectW[] = {'C','O','N','N','E','C','T',0};
const WCHAR *target = request->server->host_port;
- if (HTTP_GetCustomHeaderIndex(request, szContent_Length, 0, TRUE) >= 0)
+ if (HTTP_GetCustomHeaderIndex(request, L"Content-Length", 0, TRUE) >= 0)
set_content_length_header(request, 0, HTTP_ADDREQ_FLAG_REPLACE);
- request_header = build_request_header(request, connectW, target, g_szHttp1_1, TRUE);
+ request_header = build_request_header(request, L"CONNECT", target, L"HTTP/1.1", TRUE);
}
else if (request->proxy && !(request->hdr.dwFlags & INTERNET_FLAG_SECURE))
{
@@ -5073,7 +5001,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
}
else
{
- if (request->proxy && HTTP_GetCustomHeaderIndex(request, szContent_Length, 0, TRUE) >= 0)
+ if (request->proxy && HTTP_GetCustomHeaderIndex(request, L"Content-Length", 0, TRUE) >= 0)
set_content_length_header(request, dwContentLength, HTTP_ADDREQ_FLAG_REPLACE);
request_header = build_request_header(request, request->verb, request->path, request->version, TRUE);
@@ -5160,11 +5088,11 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
if(!new_url)
break;
- if (wcscmp(request->verb, szGET) && wcscmp(request->verb, szHEAD) &&
+ if (wcscmp(request->verb, L"GET") && wcscmp(request->verb, L"HEAD") &&
request->status_code != HTTP_STATUS_REDIRECT_KEEP_VERB)
{
heap_free(request->verb);
- request->verb = heap_strdupW(szGET);
+ request->verb = heap_strdupW(L"GET");
}
http_release_netconn(request, drain_content(request, FALSE) == ERROR_SUCCESS);
res = HTTP_HandleRedirect(request, new_url);
@@ -5243,7 +5171,7 @@ static DWORD HTTP_HttpSendRequestW(http_request_t *request, LPCWSTR lpszHeaders,
http_release_netconn( request, FALSE );
break;
}
- remove_header(request, szProxy_Authorization, TRUE);
+ remove_header(request, L"Proxy-Authorization", TRUE);
destroy_authinfo(request->proxyAuthInfo);
request->proxyAuthInfo = NULL;
request->contentLength = 0;
@@ -5354,11 +5282,11 @@ static DWORD HTTP_HttpEndRequestW(http_request_t *request, DWORD dwFlags, DWORD_
if(!new_url)
break;
- if (wcscmp(request->verb, szGET) && wcscmp(request->verb, szHEAD) &&
+ if (wcscmp(request->verb, L"GET") && wcscmp(request->verb, L"HEAD") &&
request->status_code != HTTP_STATUS_REDIRECT_KEEP_VERB)
{
heap_free(request->verb);
- request->verb = heap_strdupW(szGET);
+ request->verb = heap_strdupW(L"GET");
}
http_release_netconn(request, drain_content(request, FALSE) == ERROR_SUCCESS);
res = HTTP_HandleRedirect(request, new_url);
@@ -6006,7 +5934,7 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len)
rc += buflen;
MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
/* check is this a status code line? */
- if (!wcsncmp(buffer, g_szHttp1_0, 4))
+ if (!wcsncmp(buffer, L"HTTP/1.0", 4))
{
/* split the version from the status code */
status_code = wcschr( buffer, ' ' );
@@ -6034,22 +5962,22 @@ static DWORD HTTP_GetResponseHeaders(http_request_t *request, INT *len)
heap_free(request->statusText);
request->status_code = HTTP_STATUS_OK;
- request->version = heap_strdupW(g_szHttp1_0);
- request->statusText = heap_strdupW(szOK);
+ request->version = heap_strdupW(L"HTTP/1.0");
+ request->statusText = heap_strdupW(L"OK");
goto lend;
}
} while (codeHundred);
/* Add status code */
- HTTP_ProcessHeader(request, szStatus, status_code,
+ HTTP_ProcessHeader(request, L"Status", status_code,
HTTP_ADDHDR_FLAG_REPLACE | HTTP_ADDHDR_FLAG_ADD);
heap_free(request->version);
heap_free(request->statusText);
request->version = heap_strdupW(buffer);
- request->statusText = heap_strdupW(status_text ? status_text : emptyW);
+ request->statusText = heap_strdupW(status_text ? status_text : L"");
/* Restore the spaces */
*(status_code-1) = ' ';
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index b26a1b912ee..de56e3f3146 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -94,12 +94,7 @@ static ULONG max_conns = 2, max_1_0_conns = 4;
static ULONG connect_timeout = 60000;
static const WCHAR szInternetSettings[] =
- { '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',0 };
-static const WCHAR szProxyServer[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
-static const WCHAR szProxyEnable[] = { 'P','r','o','x','y','E','n','a','b','l','e', 0 };
-static const WCHAR szProxyOverride[] = { 'P','r','o','x','y','O','v','e','r','r','i','d','e', 0 };
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
void *alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
{
@@ -337,7 +332,7 @@ static LONG INTERNET_SaveProxySettings( proxyinfo_t *lpwpi )
if ((ret = RegOpenKeyW( HKEY_CURRENT_USER, szInternetSettings, &key )))
return ret;
- if ((ret = RegSetValueExW( key, szProxyEnable, 0, REG_DWORD, (BYTE*)&lpwpi->proxyEnabled, sizeof(DWORD))))
+ if ((ret = RegSetValueExW( key, L"ProxyEnable", 0, REG_DWORD, (BYTE*)&lpwpi->proxyEnabled, sizeof(DWORD))))
{
RegCloseKey( key );
return ret;
@@ -345,7 +340,7 @@ static LONG INTERNET_SaveProxySettings( proxyinfo_t *lpwpi )
if (lpwpi->proxy)
{
- if ((ret = RegSetValueExW( key, szProxyServer, 0, REG_SZ, (BYTE*)lpwpi->proxy, sizeof(WCHAR) * (lstrlenW(lpwpi->proxy) + 1))))
+ if ((ret = RegSetValueExW( key, L"ProxyServer", 0, REG_SZ, (BYTE*)lpwpi->proxy, sizeof(WCHAR) * (lstrlenW(lpwpi->proxy) + 1))))
{
RegCloseKey( key );
return ret;
@@ -353,7 +348,7 @@ static LONG INTERNET_SaveProxySettings( proxyinfo_t *lpwpi )
}
else
{
- if ((ret = RegDeleteValueW( key, szProxyServer )) && ret != ERROR_FILE_NOT_FOUND)
+ if ((ret = RegDeleteValueW( key, L"ProxyServer" )) && ret != ERROR_FILE_NOT_FOUND)
{
RegCloseKey( key );
return ret;
@@ -491,7 +486,6 @@ static void free_global_proxy( void )
static BOOL parse_proxy_url( proxyinfo_t *info, const WCHAR *url )
{
- static const WCHAR fmt[] = {'%','.','*','s',':','%','u',0};
URL_COMPONENTSW uc = {sizeof(uc)};
uc.dwHostNameLength = 1;
@@ -507,7 +501,7 @@ static BOOL parse_proxy_url( proxyinfo_t *info, const WCHAR *url )
return TRUE;
}
if (!(info->proxy = heap_alloc( (uc.dwHostNameLength + 12) * sizeof(WCHAR) ))) return FALSE;
- swprintf( info->proxy, uc.dwHostNameLength + 12, fmt, uc.dwHostNameLength, uc.lpszHostName, uc.nPort );
+ swprintf( info->proxy, uc.dwHostNameLength + 12, L"%.*s:%u", uc.dwHostNameLength, uc.lpszHostName, uc.nPort );
if (!uc.dwUserNameLength) info->proxyUsername = NULL;
else if (!(info->proxyUsername = heap_strndupW( uc.lpszUserName, uc.dwUserNameLength )))
@@ -562,10 +556,10 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
}
len = sizeof(DWORD);
- if (RegQueryValueExW( key, szProxyEnable, NULL, &type, (BYTE *)&lpwpi->proxyEnabled, &len ) || type != REG_DWORD)
+ if (RegQueryValueExW( key, L"ProxyEnable", NULL, &type, (BYTE *)&lpwpi->proxyEnabled, &len ) || type != REG_DWORD)
{
lpwpi->proxyEnabled = 0;
- if((ret = RegSetValueExW( key, szProxyEnable, 0, REG_DWORD, (BYTE *)&lpwpi->proxyEnabled, sizeof(DWORD) )))
+ if((ret = RegSetValueExW( key, L"ProxyEnable", 0, REG_DWORD, (BYTE *)&lpwpi->proxyEnabled, sizeof(DWORD) )))
{
FreeProxyInfo( lpwpi );
RegCloseKey( key );
@@ -576,10 +570,9 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
if (!(envproxy = _wgetenv( L"http_proxy" )) || lpwpi->proxyEnabled)
{
/* figure out how much memory the proxy setting takes */
- if (!RegQueryValueExW( key, szProxyServer, NULL, &type, NULL, &len ) && len && (type == REG_SZ))
+ if (!RegQueryValueExW( key, L"ProxyServer", NULL, &type, NULL, &len ) && len && (type == REG_SZ))
{
LPWSTR szProxy, p;
- static const WCHAR szHttp[] = {'h','t','t','p','=',0};
if (!(szProxy = heap_alloc(len)))
{
@@ -587,13 +580,13 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
FreeProxyInfo( lpwpi );
return ERROR_OUTOFMEMORY;
}
- RegQueryValueExW( key, szProxyServer, NULL, &type, (BYTE*)szProxy, &len );
+ RegQueryValueExW( key, L"ProxyServer", NULL, &type, (BYTE*)szProxy, &len );
/* find the http proxy, and strip away everything else */
- p = wcsstr( szProxy, szHttp );
+ p = wcsstr( szProxy, L"http=" );
if (p)
{
- p += lstrlenW( szHttp );
+ p += lstrlenW( L"http=" );
lstrcpyW( szProxy, p );
}
p = wcschr( szProxy, ';' );
@@ -638,7 +631,7 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
if (!(envproxy = _wgetenv( L"no_proxy" )))
{
/* figure out how much memory the proxy setting takes */
- if (!RegQueryValueExW( key, szProxyOverride, NULL, &type, NULL, &len ) && len && (type == REG_SZ))
+ if (!RegQueryValueExW( key, L"ProxyOverride", NULL, &type, NULL, &len ) && len && (type == REG_SZ))
{
LPWSTR szProxy;
@@ -647,7 +640,7 @@ static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
RegCloseKey( key );
return ERROR_OUTOFMEMORY;
}
- RegQueryValueExW( key, szProxyOverride, NULL, &type, (BYTE*)szProxy, &len );
+ RegQueryValueExW( key, L"ProxyOverride", NULL, &type, (BYTE*)szProxy, &len );
heap_free( lpwpi->proxyBypass );
lpwpi->proxyBypass = szProxy;
@@ -2384,8 +2377,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;
@@ -2395,12 +2386,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;
}
@@ -3319,10 +3310,6 @@ BOOL WINAPI InternetTimeFromSystemTimeA( const SYSTEMTIME* time, DWORD format, L
*/
BOOL WINAPI InternetTimeFromSystemTimeW( const SYSTEMTIME* time, DWORD format, LPWSTR string, DWORD size )
{
- static const WCHAR date[] =
- { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
- '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
-
TRACE( "%p 0x%08x %p 0x%08x\n", time, format, string, size );
if (!time || !string || format != INTERNET_RFC1123_FORMAT)
@@ -3337,7 +3324,7 @@ BOOL WINAPI InternetTimeFromSystemTimeW( const SYSTEMTIME* time, DWORD format, L
return FALSE;
}
- swprintf( string, size, date,
+ swprintf( string, size, L"%s, %02d %s %4d %02d:%02d:%02d GMT",
WININET_wkday[time->wDayOfWeek],
time->wDay,
WININET_month[time->wMonth - 1],
@@ -3644,8 +3631,7 @@ static HINTERNET INTERNET_InternetOpenUrlW(appinfo_t *hIC, LPCWSTR lpszUrl,
case INTERNET_SCHEME_HTTP:
case INTERNET_SCHEME_HTTPS: {
- static const WCHAR szStars[] = { '*','/','*', 0 };
- LPCWSTR accept[2] = { szStars, NULL };
+ LPCWSTR accept[2] = { L"*/*", NULL };
if (urlComponents.nScheme == INTERNET_SCHEME_HTTPS) dwFlags |= INTERNET_FLAG_SECURE;
diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c
index cc12ef9e76e..c4ca54ac87c 100644
--- a/dlls/wininet/urlcache.c
+++ b/dlls/wininet/urlcache.c
@@ -394,12 +394,10 @@ static void cache_container_create_object_name(LPWSTR lpszPath, WCHAR replace)
/* Caller must hold container lock */
static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD size, BOOL *validate)
{
- static const WCHAR mapping_name_format[]
- = {'%','s','i','n','d','e','x','.','d','a','t','_','%','l','u',0};
WCHAR mapping_name[MAX_PATH];
HANDLE mapping;
- wsprintfW(mapping_name, mapping_name_format, path, size);
+ wsprintfW(mapping_name, L"%sindex.dat_%lu", path, size);
cache_container_create_object_name(mapping_name, '_');
mapping = OpenFileMappingW(FILE_MAP_WRITE, FALSE, mapping_name);
@@ -415,13 +413,6 @@ static HANDLE cache_container_map_index(HANDLE file, const WCHAR *path, DWORD si
/* Caller must hold container lock */
static DWORD cache_container_set_size(cache_container *container, HANDLE file, DWORD blocks_no)
{
- static const WCHAR cache_content_key[] = {'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','a','c','h','e','\\','C','o','n','t','e','n','t',0};
- static const WCHAR cache_limit[] = {'C','a','c','h','e','L','i','m','i','t',0};
-
DWORD file_size = FILE_SIZE(blocks_no);
WCHAR dir_path[MAX_PATH], *dir_name;
entry_hash_table *hashtable_entry;
@@ -472,10 +463,11 @@ static DWORD cache_container_set_size(cache_container *container, HANDLE file, D
header->dirs_no = container->default_entry_type==NORMAL_CACHE_ENTRY ? 4 : 0;
/* If the registry has a cache size set, use the registry value */
- if(RegOpenKeyW(HKEY_CURRENT_USER, cache_content_key, &key) == ERROR_SUCCESS) {
+ if(RegOpenKeyW(HKEY_CURRENT_USER,
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Cache\\Content", &key) == ERROR_SUCCESS) {
DWORD dw, len = sizeof(dw), keytype;
- if(RegQueryValueExW(key, cache_limit, NULL, &keytype, (BYTE*)&dw, &len) == ERROR_SUCCESS &&
+ if(RegQueryValueExW(key, L"CacheLimit", NULL, &keytype, (BYTE*)&dw, &len) == ERROR_SUCCESS &&
keytype == REG_DWORD)
header->cache_limit.QuadPart = (ULONGLONG)dw * 1024;
RegCloseKey(key);
@@ -595,8 +587,6 @@ static BOOL cache_container_is_valid(urlcache_header *header, DWORD file_size)
*/
static DWORD cache_container_open_index(cache_container *container, DWORD blocks_no)
{
- static const WCHAR index_dat[] = {'i','n','d','e','x','.','d','a','t',0};
-
HANDLE file;
WCHAR index_path[MAX_PATH];
DWORD file_size;
@@ -610,7 +600,7 @@ static DWORD cache_container_open_index(cache_container *container, DWORD blocks
}
lstrcpyW(index_path, container->path);
- lstrcatW(index_path, index_dat);
+ lstrcatW(index_path, L"index.dat");
file = CreateFileW(index_path, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);
if(file == INVALID_HANDLE_VALUE) {
@@ -2725,9 +2715,7 @@ static BOOL urlcache_entry_create(const char *url, const char *ext, WCHAR *full_
}
for(i=0; i<255 && !generate_name; i++) {
- static const WCHAR format[] = {'[','%','u',']','%','s',0};
-
- wsprintfW(full_path+full_path_len, format, i, extW);
+ wsprintfW(full_path+full_path_len, L"[%u]%s", i, extW);
TRACE("Trying: %s\n", debugstr_w(full_path));
file = CreateFileW(full_path, GENERIC_READ, 0, NULL, CREATE_NEW, 0, NULL);
--
2.26.2