Commit 2e2ed52c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Use set_cookie directly in HTTP_ProcessCookies.

parent dce9181c
......@@ -414,7 +414,7 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
return r;
}
static BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cookie_data)
BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cookie_data)
{
cookie_domain *thisCookieDomain = NULL;
cookie *thisCookie;
......
......@@ -720,26 +720,35 @@ static void HTTP_ProcessCookies( http_request_t *request )
int numCookies = 0;
LPHTTPHEADERW setCookieHeader;
while((HeaderIndex = HTTP_GetCustomHeaderIndex(request, szSet_Cookie, numCookies, FALSE)) != -1)
if(request->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES)
return;
while((HeaderIndex = HTTP_GetCustomHeaderIndex(request, szSet_Cookie, numCookies++, FALSE)) != -1)
{
HTTPHEADERW *host;
const WCHAR *data;
WCHAR *name;
setCookieHeader = &request->custHeaders[HeaderIndex];
if (!(request->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES) && setCookieHeader->lpszValue)
{
int len;
static const WCHAR szFmt[] = { 'h','t','t','p',':','/','/','%','s','%','s',0};
LPWSTR buf_url;
LPHTTPHEADERW Host;
if (!setCookieHeader->lpszValue)
continue;
Host = HTTP_GetHeader(request, hostW);
len = lstrlenW(Host->lpszValue) + 9 + lstrlenW(request->path);
buf_url = heap_alloc(len*sizeof(WCHAR));
sprintfW(buf_url, szFmt, Host->lpszValue, request->path);
InternetSetCookieW(buf_url, NULL, setCookieHeader->lpszValue);
host = HTTP_GetHeader(request, hostW);
if(!host)
continue;
HeapFree(GetProcessHeap(), 0, buf_url);
}
numCookies++;
data = strchrW(setCookieHeader->lpszValue, '=');
if(!data)
continue;
name = heap_strndupW(setCookieHeader->lpszValue, data-setCookieHeader->lpszValue);
if(!name)
continue;
data++;
set_cookie(host->lpszValue, request->path, name, data);
heap_free(name);
}
}
......
......@@ -498,6 +498,7 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN;
BOOL get_cookie(const WCHAR*,const WCHAR*,WCHAR*,DWORD*) DECLSPEC_HIDDEN;
BOOL set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
void INTERNET_SetLastError(DWORD dwError) DECLSPEC_HIDDEN;
DWORD INTERNET_GetLastError(void) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment