From fa4c25ddf4641a77829769dc43ecb0b25d15229d Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Wed, 22 Jul 2009 11:56:33 +0200 Subject: [PATCH] wininet: Correct handling of redirected HEAD requests. --- dlls/wininet/http.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index b4f79248128..693a44fa297 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -79,6 +79,7 @@ static const WCHAR szProxy_Authorization[] = { 'P','r','o','x','y','-','A','u',' 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 szCrLf[] = {'\r','\n', 0}; static const WCHAR szAccept[] = { 'A','c','c','e','p','t',0 }; @@ -909,9 +910,11 @@ static BOOL HTTP_HttpEndRequestW(http_request_t *lpwhr, DWORD dwFlags, DWORD_PTR dwBufferSize=sizeof(szNewLocation); if (HTTP_HttpQueryInfoW(lpwhr, HTTP_QUERY_LOCATION, szNewLocation, &dwBufferSize, NULL)) { - /* redirects are always GETs */ - HeapFree(GetProcessHeap(), 0, lpwhr->lpszVerb); - lpwhr->lpszVerb = heap_strdupW(szGET); + if (strcmpW(lpwhr->lpszVerb, szGET) && strcmpW(lpwhr->lpszVerb, szHEAD)) + { + HeapFree(GetProcessHeap(), 0, lpwhr->lpszVerb); + lpwhr->lpszVerb = heap_strdupW(szGET); + } HTTP_DrainContent(lpwhr); if ((new_url = HTTP_GetRedirectURL( lpwhr, szNewLocation ))) { @@ -2526,6 +2529,7 @@ static void HTTP_DrainContent(http_request_t *req) NETCON_close(&req->netConnection); return; } + if (!strcmpW(req->lpszVerb, szHEAD)) return; do { @@ -3790,10 +3794,11 @@ BOOL WINAPI HTTP_HttpSendRequestW(http_request_t *lpwhr, LPCWSTR lpszHeaders, if ((dwStatusCode==HTTP_STATUS_REDIRECT || dwStatusCode==HTTP_STATUS_MOVED) && HTTP_HttpQueryInfoW(lpwhr,HTTP_QUERY_LOCATION,szNewLocation,&dwBufferSize,NULL)) { - /* redirects are always GETs */ - HeapFree(GetProcessHeap(), 0, lpwhr->lpszVerb); - lpwhr->lpszVerb = heap_strdupW(szGET); - + if (strcmpW(lpwhr->lpszVerb, szGET) && strcmpW(lpwhr->lpszVerb, szHEAD)) + { + HeapFree(GetProcessHeap(), 0, lpwhr->lpszVerb); + lpwhr->lpszVerb = heap_strdupW(szGET); + } HTTP_DrainContent(lpwhr); if ((new_url = HTTP_GetRedirectURL( lpwhr, szNewLocation ))) {