Aric Stewart : wininet: Improve HTTP status 100 handling.
Alexandre Julliard
julliard at winehq.org
Tue Jun 23 10:02:49 CDT 2009
Module: wine
Branch: master
Commit: b9f2f9d2265616286eb7a6271852cfdcc121ae90
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b9f2f9d2265616286eb7a6271852cfdcc121ae90
Author: Aric Stewart <aric at codeweavers.com>
Date: Tue Jun 23 14:30:38 2009 +0900
wininet: Improve HTTP status 100 handling.
---
dlls/wininet/http.c | 42 ++++++++++++++++++++++++++----------------
dlls/wininet/tests/http.c | 19 +++++++++++++++++++
2 files changed, 45 insertions(+), 16 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 6b3fb9a..2013909 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -4200,13 +4200,13 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr, BOOL clear)
DWORD buflen = MAX_REPLY_LEN;
BOOL bSuccess = FALSE;
INT rc = 0;
- static const WCHAR szHundred[] = {'1','0','0',0};
char bufferA[MAX_REPLY_LEN];
- LPWSTR status_code, status_text;
+ LPWSTR status_code = NULL, status_text = NULL;
DWORD cchMaxRawHeaders = 1024;
LPWSTR lpszRawHeaders = HeapAlloc(GetProcessHeap(), 0, (cchMaxRawHeaders+1)*sizeof(WCHAR));
LPWSTR temp;
DWORD cchRawHeaders = 0;
+ BOOL codeHundred = FALSE;
TRACE("-->\n");
@@ -4217,6 +4217,7 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr, BOOL clear)
goto lend;
do {
+ static const WCHAR szHundred[] = {'1','0','0',0};
/*
* We should first receive 'HTTP/1.x nnn OK' where nnn is the status code.
*/
@@ -4225,23 +4226,32 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr, BOOL clear)
goto lend;
rc += buflen;
MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
+ /* check is this a status code line? */
+ if (!strncmpW(buffer, g_szHttp1_0, 4))
+ {
+ /* split the version from the status code */
+ status_code = strchrW( buffer, ' ' );
+ if( !status_code )
+ goto lend;
+ *status_code++=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;
+ /* 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) );
+ 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 */
+ codeHundred = (!strcmpW(status_code, szHundred));
+ }
+ else if (!codeHundred)
+ {
+ FIXME("Non status line at head of response (%s)\n",debugstr_w(buffer));
+ continue;
+ }
+ } while (codeHundred);
/* Add status code */
HTTP_ProcessHeader(lpwhr, szStatus, status_code,
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index f7994c5..bf6ca02 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1482,9 +1482,18 @@ done:
ok(InternetCloseHandle(hSession), "Close session handle failed\n");
}
+static const char garbagemsg[] =
+"Garbage: Header\r\n";
+
static const char contmsg[] =
"HTTP/1.1 100 Continue\r\n";
+static const char expandcontmsg[] =
+"HTTP/1.1 100 Continue\r\n"
+"Server: winecontinue\r\n"
+"Tag: something witty\r\n"
+"\r\n";
+
static const char okmsg[] =
"HTTP/1.1 200 OK\r\n"
"Server: winetest\r\n"
@@ -1710,6 +1719,15 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, page1, sizeof page1-1, 0);
last_request = 1;
}
+ if (strstr(buffer, "GET /testF"))
+ {
+ send(c, expandcontmsg, sizeof expandcontmsg-1, 0);
+ send(c, garbagemsg, sizeof garbagemsg-1, 0);
+ send(c, contmsg, sizeof contmsg-1, 0);
+ send(c, garbagemsg, sizeof garbagemsg-1, 0);
+ send(c, okmsg, sizeof okmsg-1, 0);
+ send(c, page1, sizeof page1-1, 0);
+ }
shutdown(c, 2);
closesocket(c);
@@ -2316,6 +2334,7 @@ static void test_http_connection(void)
test_basic_request(si.port, "RPC_IN_DATA", "/test5");
test_basic_request(si.port, "RPC_OUT_DATA", "/test5");
test_basic_request(si.port, "GET", "/test6");
+ test_basic_request(si.port, "GET", "/testF");
test_connection_header(si.port);
test_http1_1(si.port);
test_cookie_header(si.port);
More information about the wine-cvs
mailing list