[4/5] winhttp: Set last error if the server didn't return a valid response.
Hans Leidekker
hans at codeweavers.com
Sat Jul 23 11:15:37 CDT 2011
---
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);
--
1.7.4.1
More information about the wine-patches
mailing list