Commit 2617fb6d authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wininet: Handle the "100 Continue" response by ignoring it.

parent d0033dba
...@@ -3020,6 +3020,7 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr) ...@@ -3020,6 +3020,7 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr)
BOOL bSuccess = FALSE; BOOL bSuccess = FALSE;
INT rc = 0; INT rc = 0;
static const WCHAR szCrLf[] = {'\r','\n',0}; static const WCHAR szCrLf[] = {'\r','\n',0};
static const WCHAR szHundred[] = {'1','0','0',0};
char bufferA[MAX_REPLY_LEN]; char bufferA[MAX_REPLY_LEN];
LPWSTR status_code, status_text; LPWSTR status_code, status_text;
DWORD cchMaxRawHeaders = 1024; DWORD cchMaxRawHeaders = 1024;
...@@ -3034,32 +3035,21 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr) ...@@ -3034,32 +3035,21 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr)
if (!NETCON_connected(&lpwhr->netConnection)) if (!NETCON_connected(&lpwhr->netConnection))
goto lend; goto lend;
do {
/* /*
* HACK peek at the buffer * HACK peek at the buffer
*/ */
buflen = MAX_REPLY_LEN;
NETCON_recv(&lpwhr->netConnection, buffer, buflen, MSG_PEEK, &rc); NETCON_recv(&lpwhr->netConnection, buffer, buflen, MSG_PEEK, &rc);
/* /*
* We should first receive 'HTTP/1.x nnn OK' where nnn is the status code. * 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); memset(buffer, 0, MAX_REPLY_LEN);
if (!NETCON_getNextLine(&lpwhr->netConnection, bufferA, &buflen)) if (!NETCON_getNextLine(&lpwhr->netConnection, bufferA, &buflen))
goto lend; goto lend;
MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN ); MultiByteToWideChar( CP_ACP, 0, bufferA, buflen, buffer, MAX_REPLY_LEN );
/* regenerate raw headers */
while (cchRawHeaders + buflen + strlenW(szCrLf) > cchMaxRawHeaders)
{
cchMaxRawHeaders *= 2;
lpszRawHeaders = HeapReAlloc(GetProcessHeap(), 0, lpszRawHeaders, (cchMaxRawHeaders+1)*sizeof(WCHAR));
}
memcpy(lpszRawHeaders+cchRawHeaders, buffer, (buflen-1)*sizeof(WCHAR));
cchRawHeaders += (buflen-1);
memcpy(lpszRawHeaders+cchRawHeaders, szCrLf, sizeof(szCrLf));
cchRawHeaders += sizeof(szCrLf)/sizeof(szCrLf[0])-1;
lpszRawHeaders[cchRawHeaders] = '\0';
/* split the version from the status code */ /* split the version from the status code */
status_code = strchrW( buffer, ' ' ); status_code = strchrW( buffer, ' ' );
if( !status_code ) if( !status_code )
...@@ -3075,6 +3065,20 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr) ...@@ -3075,6 +3065,20 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr)
TRACE("version [%s] status code [%s] status text [%s]\n", TRACE("version [%s] status code [%s] status text [%s]\n",
debugstr_w(buffer), debugstr_w(status_code), debugstr_w(status_text) ); 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)
{
cchMaxRawHeaders *= 2;
lpszRawHeaders = HeapReAlloc(GetProcessHeap(), 0, lpszRawHeaders, (cchMaxRawHeaders+1)*sizeof(WCHAR));
}
memcpy(lpszRawHeaders+cchRawHeaders, buffer, (buflen-1)*sizeof(WCHAR));
cchRawHeaders += (buflen-1);
memcpy(lpszRawHeaders+cchRawHeaders, szCrLf, sizeof(szCrLf));
cchRawHeaders += sizeof(szCrLf)/sizeof(szCrLf[0])-1;
lpszRawHeaders[cchRawHeaders] = '\0';
HTTP_ProcessHeader(lpwhr, szStatus, status_code, HTTP_ProcessHeader(lpwhr, szStatus, status_code,
HTTP_ADDHDR_FLAG_REPLACE); HTTP_ADDHDR_FLAG_REPLACE);
......
...@@ -1305,18 +1305,21 @@ done: ...@@ -1305,18 +1305,21 @@ done:
ok(InternetCloseHandle(hSession), "Close session handle failed\n"); ok(InternetCloseHandle(hSession), "Close session handle failed\n");
} }
static const char contmsg[] =
"HTTP/1.1 100 Continue\r\n";
static const char okmsg[] = static const char okmsg[] =
"HTTP/1.0 200 OK\r\n" "HTTP/1.1 200 OK\r\n"
"Server: winetest\r\n" "Server: winetest\r\n"
"\r\n"; "\r\n";
static const char notokmsg[] = static const char notokmsg[] =
"HTTP/1.0 400 Bad Request\r\n" "HTTP/1.1 400 Bad Request\r\n"
"Server: winetest\r\n" "Server: winetest\r\n"
"\r\n"; "\r\n";
static const char noauthmsg[] = static const char noauthmsg[] =
"HTTP/1.0 401 Unauthorized\r\n" "HTTP/1.1 401 Unauthorized\r\n"
"Server: winetest\r\n" "Server: winetest\r\n"
"\r\n"; "\r\n";
...@@ -1435,6 +1438,14 @@ static DWORD CALLBACK server_thread(LPVOID param) ...@@ -1435,6 +1438,14 @@ static DWORD CALLBACK server_thread(LPVOID param)
send(c, notokmsg, sizeof notokmsg-1, 0); 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")) if (strstr(buffer, "GET /quit"))
{ {
send(c, okmsg, sizeof okmsg-1, 0); send(c, okmsg, sizeof okmsg-1, 0);
...@@ -1663,6 +1674,7 @@ static void test_http_connection(void) ...@@ -1663,6 +1674,7 @@ static void test_http_connection(void)
test_proxy_direct(si.port); test_proxy_direct(si.port);
test_header_handling_order(si.port); test_header_handling_order(si.port);
test_basic_request(si.port, "POST", "/test5"); test_basic_request(si.port, "POST", "/test5");
test_basic_request(si.port, "GET", "/test6");
/* send the basic request again to shutdown the server thread */ /* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit"); test_basic_request(si.port, "GET", "/quit");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment