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

oldstable
Hans Leidekker 2008-02-17 20:41:56 +01:00 committed by Alexandre Julliard
parent d0033dbaed
commit 2617fb6dea
2 changed files with 46 additions and 30 deletions

View File

@ -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);

View File

@ -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");