wininet: Correct handling of redirected HEAD requests.
Hans Leidekker
hans at codeweavers.com
Wed Jul 22 04:56:33 CDT 2009
Unlike other verbs, a HEAD request must not be converted to a GET request
on a redirect, and there is no content to drain.
Fixes http://bugs.winehq.org/show_bug.cgi?id=19351
-Hans
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index b4f7924..693a44f 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 )))
{
More information about the wine-patches
mailing list