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, ...@@ -414,7 +414,7 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
return r; 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_domain *thisCookieDomain = NULL;
cookie *thisCookie; cookie *thisCookie;
......
...@@ -720,26 +720,35 @@ static void HTTP_ProcessCookies( http_request_t *request ) ...@@ -720,26 +720,35 @@ static void HTTP_ProcessCookies( http_request_t *request )
int numCookies = 0; int numCookies = 0;
LPHTTPHEADERW setCookieHeader; 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]; setCookieHeader = &request->custHeaders[HeaderIndex];
if (!(request->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES) && setCookieHeader->lpszValue) if (!setCookieHeader->lpszValue)
{ continue;
int len;
static const WCHAR szFmt[] = { 'h','t','t','p',':','/','/','%','s','%','s',0};
LPWSTR buf_url;
LPHTTPHEADERW Host;
Host = HTTP_GetHeader(request, hostW); host = HTTP_GetHeader(request, hostW);
len = lstrlenW(Host->lpszValue) + 9 + lstrlenW(request->path); if(!host)
buf_url = heap_alloc(len*sizeof(WCHAR)); continue;
sprintfW(buf_url, szFmt, Host->lpszValue, request->path);
InternetSetCookieW(buf_url, NULL, setCookieHeader->lpszValue);
HeapFree(GetProcessHeap(), 0, buf_url); data = strchrW(setCookieHeader->lpszValue, '=');
} if(!data)
numCookies++; 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, ...@@ -498,6 +498,7 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN; struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN;
BOOL get_cookie(const WCHAR*,const WCHAR*,WCHAR*,DWORD*) 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; void INTERNET_SetLastError(DWORD dwError) DECLSPEC_HIDDEN;
DWORD INTERNET_GetLastError(void) 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