Hans Leidekker : wininet:
Process caller supplied headers after inserting connection and
authorization headers , not before.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Aug 10 07:31:08 CDT 2007
Module: wine
Branch: master
Commit: bb9413d77a2002c5a76f01b56c9ec1d5092d2c9a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bb9413d77a2002c5a76f01b56c9ec1d5092d2c9a
Author: Hans Leidekker <hans at it.vu.nl>
Date: Thu Aug 9 21:43:25 2007 +0200
wininet: Process caller supplied headers after inserting connection and authorization headers, not before.
---
dlls/wininet/http.c | 13 ++++----
dlls/wininet/tests/http.c | 74 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 7 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 8c50ec9..33cfbb5 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2596,6 +2596,12 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
}
HTTP_FixURL(lpwhr);
+ HTTP_ProcessHeader(lpwhr, szConnection,
+ lpwhr->hdr.dwFlags & INTERNET_FLAG_KEEP_CONNECTION ? szKeepAlive : szClose,
+ HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_REPLACE);
+
+ HTTP_InsertAuthorization(lpwhr);
+ HTTP_InsertProxyAuthorization(lpwhr);
/* add the headers the caller supplied */
if( lpszHeaders && dwHeaderLength )
@@ -2604,13 +2610,6 @@ BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REPLACE);
}
- HTTP_ProcessHeader(lpwhr, szConnection,
- lpwhr->hdr.dwFlags & INTERNET_FLAG_KEEP_CONNECTION ? szKeepAlive : szClose,
- HTTP_ADDHDR_FLAG_REQ | HTTP_ADDHDR_FLAG_REPLACE);
-
- HTTP_InsertAuthorization(lpwhr);
- HTTP_InsertProxyAuthorization(lpwhr);
-
requestString = HTTP_BuildHeaderRequestString(lpwhr, lpwhr->lpszVerb, lpwhr->lpszPath, FALSE);
TRACE("Request header -> %s\n", debugstr_w(requestString) );
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 9c1327c..5d0b0bb 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1128,6 +1128,16 @@ static const char okmsg[] =
"Server: winetest\r\n"
"\r\n";
+static const char notokmsg[] =
+"HTTP/1.0 400 Bad Request\r\n"
+"Server: winetest\r\n"
+"\r\n";
+
+static const char noauthmsg[] =
+"HTTP/1.0 401 Unauthorized\r\n"
+"Server: winetest\r\n"
+"\r\n";
+
static const char proxymsg[] =
"HTTP/1.1 407 Proxy Authentication Required\r\n"
"Server: winetest\r\n"
@@ -1210,6 +1220,22 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, proxymsg, sizeof proxymsg-1, 0);
}
+ if (strstr(buffer, "/test3"))
+ {
+ if (strstr(buffer, "Authorization: Basic dXNlcjpwd2Q="))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, noauthmsg, sizeof noauthmsg-1, 0);
+ }
+
+ if (strstr(buffer, "/test4"))
+ {
+ if (strstr(buffer, "Connection: Close"))
+ send(c, okmsg, sizeof okmsg-1, 0);
+ else
+ send(c, notokmsg, sizeof notokmsg-1, 0);
+ }
+
if (strstr(buffer, "/quit"))
{
send(c, okmsg, sizeof okmsg-1, 0);
@@ -1366,6 +1392,53 @@ static void test_proxy_direct(int port)
InternetCloseHandle(hi);
}
+static void test_header_handling_order(int port)
+{
+ static char authorization[] = "Authorization: Basic dXNlcjpwd2Q=";
+ static char connection[] = "Connection: Close";
+
+ static const char *types[2] = { "*", NULL };
+ HINTERNET session, connect, request;
+ DWORD size, status;
+ BOOL ret;
+
+ session = InternetOpen("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(session != NULL, "InternetOpen failed\n");
+
+ connect = InternetConnect(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequest(connect, NULL, "/test3", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequest(request, authorization, ~0UL, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ status = 0;
+ size = sizeof(status);
+ ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+ ok(ret, "HttpQueryInfo failed\n");
+ ok(status == 200, "request failed with status %u\n", status);
+
+ InternetCloseHandle(request);
+
+ request = HttpOpenRequest(connect, NULL, "/test4", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+
+ ret = HttpSendRequest(request, connection, ~0UL, NULL, 0);
+ ok(ret, "HttpSendRequest failed\n");
+
+ status = 0;
+ size = sizeof(status);
+ ret = HttpQueryInfo( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL );
+ ok(ret, "HttpQueryInfo failed\n");
+ ok(status == 200, "request failed with status %u\n", status);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+ InternetCloseHandle(session);
+}
+
static void test_http_connection(void)
{
struct server_info si;
@@ -1386,6 +1459,7 @@ static void test_http_connection(void)
test_basic_request(si.port, "/test1");
test_proxy_indirect(si.port);
test_proxy_direct(si.port);
+ test_header_handling_order(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "/quit");
More information about the wine-cvs
mailing list