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
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://") */;
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;
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);
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);
}
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));
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;
/* 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++)
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),
}
}
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 );
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;
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),
}
}
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);
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;
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);
*/
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)
/* 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;
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)))
{
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);
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 != '*')
*/
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;
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;
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));
/* 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;
}
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;
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;
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;
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;
}
/* 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;
}
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;
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);
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 );
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)
{
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 );
}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));
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;
}
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);
{
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));
}
/* 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;
}
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 };
/* 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;
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;
while (iswspace(*ptr))
ptr++;
- if (wcscmp(ptr, gmt))
+ if (wcscmp(ptr, L"GMT"))
{
ERR("unexpected time zone %s\n", debugstr_w(ptr));
return FALSE;
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;
while (iswspace(*ptr))
ptr++;
- if (wcscmp(ptr, gmt))
+ if (wcscmp(ptr, L"GMT"))
{
ERR("unexpected time zone %s\n", debugstr_w(ptr));
return FALSE;
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;
/* 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];
;
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;
}
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];
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];
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 );
}
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 );
}
/* 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;
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 */
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 );
}
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);
}
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))
{
}
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);
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);
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;
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);
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, ' ' );
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) = ' ';
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)
{
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;
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;
}
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;
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;
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 )))
}
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 );
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)))
{
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, ';' );
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;
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;
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;
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;
}
*/
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)
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],
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;