winhttp: Set last error if the server didn't return a valid response.

This commit is contained in:
Hans Leidekker 2011-07-23 18:15:37 +02:00 committed by Alexandre Julliard
parent b218ed1a69
commit 694d43a910
2 changed files with 9 additions and 2 deletions

View File

@ -1828,8 +1828,11 @@ static BOOL receive_response( request_t *request, BOOL async )
for (;;)
{
if (!(ret = read_reply( request ))) break;
if (!(ret = read_reply( request )))
{
set_last_error( ERROR_WINHTTP_INVALID_SERVER_RESPONSE );
break;
}
size = sizeof(DWORD);
query = WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER;
if (!(ret = query_headers( request, query, NULL, &status, &size, NULL ))) break;

View File

@ -1955,6 +1955,7 @@ static void test_no_headers(int port)
{
static const WCHAR no_headersW[] = {'/','n','o','_','h','e','a','d','e','r','s',0};
HINTERNET ses, con, req;
DWORD error;
BOOL ret;
ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0);
@ -1969,8 +1970,11 @@ static void test_no_headers(int port)
ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
ok(ret, "failed to send request %u\n", GetLastError());
SetLastError(0xdeadbeef);
ret = WinHttpReceiveResponse(req, NULL);
error = GetLastError();
ok(!ret, "expected failure\n");
ok(error == ERROR_WINHTTP_INVALID_SERVER_RESPONSE, "got %u\n", error);
WinHttpCloseHandle(req);
WinHttpCloseHandle(con);