Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/httpapi/httpapi_main.c | 21 ++++++++++++++------- dlls/httpapi/tests/httpapi.c | 11 +++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/dlls/httpapi/httpapi_main.c b/dlls/httpapi/httpapi_main.c index 6143214346..9904ed18db 100644 --- a/dlls/httpapi/httpapi_main.c +++ b/dlls/httpapi/httpapi_main.c @@ -304,13 +304,17 @@ ULONG WINAPI HttpReceiveRequestEntityBody(HANDLE queue, HTTP_REQUEST_ID id, ULON ovl = &sync_ovl; }
- if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_BODY, ¶ms, sizeof(params), buffer, size, NULL, ovl)) + if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_BODY, ¶ms, sizeof(params), buffer, size, ret_size, ovl)) ret = GetLastError();
if (ovl == &sync_ovl) { - if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) - ret = GetLastError(); + if (ret == ERROR_IO_PENDING) + { + ret = ERROR_SUCCESS; + if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) + ret = GetLastError(); + } CloseHandle(sync_ovl.hEvent); }
@@ -348,14 +352,17 @@ ULONG WINAPI HttpReceiveHttpRequest(HANDLE queue, HTTP_REQUEST_ID id, ULONG flag ovl = &sync_ovl; }
- if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_REQUEST, ¶ms, sizeof(params), request, size, NULL, ovl)) + if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_REQUEST, ¶ms, sizeof(params), request, size, ret_size, ovl)) ret = GetLastError();
if (ovl == &sync_ovl) { - ret = ERROR_SUCCESS; - if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) - ret = GetLastError(); + if (ret == ERROR_IO_PENDING) + { + ret = ERROR_SUCCESS; + if (!GetOverlappedResult(queue, ovl, ret_size, TRUE)) + ret = GetLastError(); + } CloseHandle(sync_ovl.hEvent); }
diff --git a/dlls/httpapi/tests/httpapi.c b/dlls/httpapi/tests/httpapi.c index 252a712a96..01d8e4fffc 100644 --- a/dlls/httpapi/tests/httpapi.c +++ b/dlls/httpapi/tests/httpapi.c @@ -188,6 +188,10 @@ static void test_v1_server(void) ret = CloseHandle(queue2); ok(ret, "Failed to close queue handle, error %u.\n", GetLastError());
+ ret_size = 0xdeadbeef; + ret = HttpReceiveHttpRequest(NULL, HTTP_NULL_ID, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), &ret_size, NULL); + ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); + ok(!ret_size, "Got size %u.\n", ret_size); ret = HttpReceiveHttpRequest(NULL, HTTP_NULL_ID, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), NULL, &ovl); ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); ret = HttpReceiveHttpRequest(queue, 0xdeadbeef, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), NULL, &ovl); @@ -791,6 +795,13 @@ static void test_v1_entity_body(void)
/* Test HttpReceiveRequestEntityBody(). */
+ ret_size = 0xdeadbeef; + ret = HttpReceiveRequestEntityBody(NULL, HTTP_NULL_ID, 0, recv_body, sizeof(recv_body), &ret_size, NULL); + ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); + ok(!ret_size, "Got size %u.\n", ret_size); + ret = HttpReceiveRequestEntityBody(NULL, HTTP_NULL_ID, 0, recv_body, sizeof(recv_body), NULL, &ovl); + ok(ret == ERROR_INVALID_HANDLE, "Got error %u.\n", ret); + sprintf(req_text, post_req, port); ret = send(s, req_text, strlen(req_text) + 1, 0); ok(ret == strlen(req_text) + 1, "send() returned %d.\n", ret);