From 2e2ed52cfb0dad4cf7742ff2b82ac2597678f9af Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 19 May 2011 16:11:45 +0200 Subject: [PATCH] wininet: Use set_cookie directly in HTTP_ProcessCookies. --- dlls/wininet/cookie.c | 2 +- dlls/wininet/http.c | 39 ++++++++++++++++++++++++--------------- dlls/wininet/internet.h | 1 + 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c index d3c62326634..77e22ac1af6 100644 --- a/dlls/wininet/cookie.c +++ b/dlls/wininet/cookie.c @@ -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; diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 53bbde2fa59..883e574da08 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -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); } } diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index f94942a5ee8..aedb2654187 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -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; -- 2.11.4.GIT