From 694d43a91068caa5f67717ca7bf699cbae1806be Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Sat, 23 Jul 2011 18:15:37 +0200 Subject: [PATCH] winhttp: Set last error if the server didn't return a valid response. --- dlls/winhttp/request.c | 7 +++++-- dlls/winhttp/tests/winhttp.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index d17057306f7..8f41df853a0 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -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; diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index acffece201d..28ab72d4ffe 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -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);