Module: wine Branch: master Commit: 694d43a91068caa5f67717ca7bf699cbae1806be URL: http://source.winehq.org/git/wine.git/?a=commit;h=694d43a91068caa5f67717ca7b...
Author: Hans Leidekker hans@codeweavers.com Date: Sat Jul 23 18:15:37 2011 +0200
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 d170573..8f41df8 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 acffece..28ab72d 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);