Hans Leidekker : wininet: Handle the "100 Continue" response by ignoring it .
Alexandre Julliard
julliard at winehq.org
Mon Feb 18 08:50:44 CST 2008
Module: wine
Branch: master
Commit: 2617fb6dea8e114ef2ade1c0167147b531194e31
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2617fb6dea8e114ef2ade1c0167147b531194e31
Author: Hans Leidekker <hans at it.vu.nl>
Date: Sun Feb 17 20:41:56 2008 +0100
wininet: Handle the "100 Continue" response by ignoring it.
---
dlls/wininet/http.c | 58 ++++++++++++++++++++++++---------------------
dlls/wininet/tests/http.c | 18 +++++++++++--
2 files changed, 46 insertions(+), 30 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 8f932c3..63491d0 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3020,6 +3020,7 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr)
BOOL bSuccess = FALSE;
INT rc = 0;
static const WCHAR szCrLf[] = {'\r','\n',0};
+ static const WCHAR szHundred[] = {'1','0','0',0};
char bufferA[MAX_REPLY_LEN];
LPWSTR status_code, status_text;
DWORD cchMaxRawHeaders = 1024;
@@ -3034,19 +3035,37 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr)
if (!NETCON_connected(&lpwhr->netConnection))
goto lend;
- /*
- * HACK peek at the buffer
- */
- NETCON_recv(&lpwhr->netConnection, buffer, buflen, MSG_PEEK, &rc);
+ do {
+ /*
+ * HACK peek at the buffer
+ */
+ buflen = MAX_REPLY_LEN;
+ NETCON_recv(&lpwhr->netConnection, buffer, buflen, MSG_PEEK, &rc);
- /*
- * We should first receive 'HTTP/1.x nnn OK' where nnn is the status code.
- */
- buflen = MAX_REPLY_LEN;
- memset(buffer, 0, MAX_REPLY_LEN);
- if (!NETCON_getNextLine(&lpwhr->netConnection, bufferA, &buflen))
- goto lend;
- MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
+ /*
+ * We should first receive 'HTTP/1.x nnn OK' where nnn is the status code.
+ */
+ memset(buffer, 0, MAX_REPLY_LEN);
+ if (!NETCON_getNextLine(&lpwhr->netConnection, bufferA, &buflen))
+ goto lend;
+ MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
+
+ /* split the version from the status code */
+ status_code = strchrW( buffer, ' ' );
+ if( !status_code )
+ goto lend;
+ *status_code++=0;
+
+ /* split the status code from the status text */
+ status_text = strchrW( status_code, ' ' );
+ if( !status_text )
+ goto lend;
+ *status_text++=0;
+
+ TRACE("version [%s] status code [%s] status text [%s]\n",
+ debugstr_w(buffer), debugstr_w(status_code), debugstr_w(status_text) );
+
+ } while (!strcmpW(status_code, szHundred)); /* ignore "100 Continue" responses */
/* regenerate raw headers */
while (cchRawHeaders + buflen + strlenW(szCrLf) > cchMaxRawHeaders)
@@ -3060,21 +3079,6 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr)
cchRawHeaders += sizeof(szCrLf)/sizeof(szCrLf[0])-1;
lpszRawHeaders[cchRawHeaders] = '\0';
- /* split the version from the status code */
- status_code = strchrW( buffer, ' ' );
- if( !status_code )
- goto lend;
- *status_code++=0;
-
- /* split the status code from the status text */
- status_text = strchrW( status_code, ' ' );
- if( !status_text )
- goto lend;
- *status_text++=0;
-
- TRACE("version [%s] status code [%s] status text [%s]\n",
- debugstr_w(buffer), debugstr_w(status_code), debugstr_w(status_text) );
-
HTTP_ProcessHeader(lpwhr, szStatus, status_code,
HTTP_ADDHDR_FLAG_REPLACE);
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 910771d..4aed85d 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1305,18 +1305,21 @@ done:
ok(InternetCloseHandle(hSession), "Close session handle failed\n");
}
+static const char contmsg[] =
+"HTTP/1.1 100 Continue\r\n";
+
static const char okmsg[] =
-"HTTP/1.0 200 OK\r\n"
+"HTTP/1.1 200 OK\r\n"
"Server: winetest\r\n"
"\r\n";
static const char notokmsg[] =
-"HTTP/1.0 400 Bad Request\r\n"
+"HTTP/1.1 400 Bad Request\r\n"
"Server: winetest\r\n"
"\r\n";
static const char noauthmsg[] =
-"HTTP/1.0 401 Unauthorized\r\n"
+"HTTP/1.1 401 Unauthorized\r\n"
"Server: winetest\r\n"
"\r\n";
@@ -1435,6 +1438,14 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, notokmsg, sizeof notokmsg-1, 0);
}
+ if (strstr(buffer, "GET /test6"))
+ {
+ send(c, contmsg, sizeof contmsg-1, 0);
+ send(c, contmsg, sizeof contmsg-1, 0);
+ send(c, okmsg, sizeof okmsg-1, 0);
+ send(c, page1, sizeof page1-1, 0);
+ }
+
if (strstr(buffer, "GET /quit"))
{
send(c, okmsg, sizeof okmsg-1, 0);
@@ -1663,6 +1674,7 @@ static void test_http_connection(void)
test_proxy_direct(si.port);
test_header_handling_order(si.port);
test_basic_request(si.port, "POST", "/test5");
+ test_basic_request(si.port, "GET", "/test6");
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");
More information about the wine-cvs
mailing list