httpapi: Implement HttpReceiveRequestEntityBody().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48017 Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9200897849
commit
c1a62e0167
|
@ -284,12 +284,37 @@ ULONG WINAPI HttpRemoveUrl(HANDLE queue, const WCHAR *url)
|
||||||
ULONG WINAPI HttpReceiveRequestEntityBody(HANDLE queue, HTTP_REQUEST_ID id, ULONG flags,
|
ULONG WINAPI HttpReceiveRequestEntityBody(HANDLE queue, HTTP_REQUEST_ID id, ULONG flags,
|
||||||
void *buffer, ULONG size, ULONG *ret_size, OVERLAPPED *ovl)
|
void *buffer, ULONG size, ULONG *ret_size, OVERLAPPED *ovl)
|
||||||
{
|
{
|
||||||
*ret_size = 0;
|
struct http_receive_body_params params =
|
||||||
|
{
|
||||||
|
.id = id,
|
||||||
|
.bits = sizeof(void *) * 8,
|
||||||
|
};
|
||||||
|
ULONG ret = ERROR_SUCCESS;
|
||||||
|
OVERLAPPED sync_ovl;
|
||||||
|
|
||||||
FIXME("stub: queue %p, id %s, flags %#x, buffer %p, size %#x, ret_size %p, ovl %p.\n",
|
TRACE("queue %p, id %s, flags %#x, buffer %p, size %#x, ret_size %p, ovl %p.\n",
|
||||||
queue, wine_dbgstr_longlong(id), flags, buffer, size, ret_size, ovl);
|
queue, wine_dbgstr_longlong(id), flags, buffer, size, ret_size, ovl);
|
||||||
|
|
||||||
return ERROR_HANDLE_EOF;
|
if (flags)
|
||||||
|
FIXME("Ignoring flags %#x.\n", flags);
|
||||||
|
|
||||||
|
if (!ovl)
|
||||||
|
{
|
||||||
|
sync_ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||||
|
ovl = &sync_ovl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DeviceIoControl(queue, IOCTL_HTTP_RECEIVE_BODY, ¶ms, sizeof(params), buffer, size, NULL, ovl))
|
||||||
|
ret = GetLastError();
|
||||||
|
|
||||||
|
if (ovl == &sync_ovl)
|
||||||
|
{
|
||||||
|
if (!GetOverlappedResult(queue, ovl, ret_size, TRUE))
|
||||||
|
ret = GetLastError();
|
||||||
|
CloseHandle(sync_ovl.hEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
|
@ -546,12 +546,13 @@ static void test_v1_short_buffer(void)
|
||||||
|
|
||||||
static void test_v1_entity_body(void)
|
static void test_v1_entity_body(void)
|
||||||
{
|
{
|
||||||
char DECLSPEC_ALIGN(8) req_buffer[4096], response_buffer[2048], req_body[2048];
|
char DECLSPEC_ALIGN(8) req_buffer[4096], response_buffer[2048], req_body[2048], recv_body[2000];
|
||||||
HTTP_REQUEST_V1 *req = (HTTP_REQUEST_V1 *)req_buffer;
|
HTTP_REQUEST_V1 *req = (HTTP_REQUEST_V1 *)req_buffer;
|
||||||
HTTP_RESPONSE_V1 response = {};
|
HTTP_RESPONSE_V1 response = {};
|
||||||
HTTP_DATA_CHUNK chunks[2] = {};
|
HTTP_DATA_CHUNK chunks[2] = {};
|
||||||
ULONG ret, chunk_size;
|
ULONG ret, chunk_size;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
OVERLAPPED ovl;
|
||||||
DWORD ret_size;
|
DWORD ret_size;
|
||||||
HANDLE queue;
|
HANDLE queue;
|
||||||
SOCKET s;
|
SOCKET s;
|
||||||
|
@ -571,6 +572,8 @@ static void test_v1_entity_body(void)
|
||||||
"Content-Length: 2048\r\n"
|
"Content-Length: 2048\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
|
|
||||||
|
ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(req_body); ++i)
|
for (i = 0; i < sizeof(req_body); ++i)
|
||||||
req_body[i] = i / 111;
|
req_body[i] = i / 111;
|
||||||
|
|
||||||
|
@ -708,6 +711,119 @@ static void test_v1_entity_body(void)
|
||||||
|
|
||||||
send_response_v1(queue, req->RequestId, s);
|
send_response_v1(queue, req->RequestId, s);
|
||||||
|
|
||||||
|
/* Test HttpReceiveRequestEntityBody(). */
|
||||||
|
|
||||||
|
ret = send(s, post_req, sizeof(post_req), 0);
|
||||||
|
ok(ret == sizeof(post_req), "send() returned %d.\n", ret);
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
ret = HttpReceiveHttpRequest(queue, HTTP_NULL_ID, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, HTTP_NULL_ID, 0, recv_body, sizeof(recv_body), &ret_size, NULL);
|
||||||
|
ok(ret == ERROR_CONNECTION_INVALID, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
ret_size = 0xdeadbeef;
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
ok(ret_size == 5, "Got size %u.\n", ret_size);
|
||||||
|
ok(!memcmp(recv_body, "ping", 5), "Entity body didn't match.\n");
|
||||||
|
|
||||||
|
ret_size = 0xdeadbeef;
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), &ret_size, NULL);
|
||||||
|
ok(ret == ERROR_HANDLE_EOF, "Got error %u.\n", ret);
|
||||||
|
ok(ret_size == 0xdeadbeef || !ret_size /* Win10+ */, "Got size %u.\n", ret_size);
|
||||||
|
|
||||||
|
send_response_v1(queue, req->RequestId, s);
|
||||||
|
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), &ret_size, NULL);
|
||||||
|
ok(ret == ERROR_CONNECTION_INVALID, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
ret = send(s, post_req, sizeof(post_req), 0);
|
||||||
|
ok(ret == sizeof(post_req), "send() returned %d.\n", ret);
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
ret = HttpReceiveHttpRequest(queue, HTTP_NULL_ID, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
memset(recv_body, 0xcc, sizeof(recv_body));
|
||||||
|
ret_size = 0xdeadbeef;
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, 2, &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
ok(ret_size == 2, "Got size %u.\n", ret_size);
|
||||||
|
ok(!memcmp(recv_body, "pi", 2), "Entity body didn't match.\n");
|
||||||
|
|
||||||
|
ret_size = 0xdeadbeef;
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, 4, &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
ok(ret_size == 3, "Got size %u.\n", ret_size);
|
||||||
|
ok(!memcmp(recv_body, "ng", 3), "Entity body didn't match.\n");
|
||||||
|
|
||||||
|
ret_size = 0xdeadbeef;
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), &ret_size, NULL);
|
||||||
|
ok(ret == ERROR_HANDLE_EOF, "Got error %u.\n", ret);
|
||||||
|
ok(ret_size == 0xdeadbeef || !ret_size /* Win10+ */, "Got size %u.\n", ret_size);
|
||||||
|
|
||||||
|
send_response_v1(queue, req->RequestId, s);
|
||||||
|
|
||||||
|
ret = send(s, post_req, sizeof(post_req), 0);
|
||||||
|
ok(ret == sizeof(post_req), "send() returned %d.\n", ret);
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
ret = HttpReceiveHttpRequest(queue, HTTP_NULL_ID, 0, (HTTP_REQUEST *)req, sizeof(req_buffer), &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
memset(recv_body, 0xcc, sizeof(recv_body));
|
||||||
|
ret_size = 0xdeadbeef;
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), NULL, &ovl);
|
||||||
|
ok(!ret || ret == ERROR_IO_PENDING, "Got error %u.\n", ret);
|
||||||
|
ret = GetOverlappedResult(queue, &ovl, &ret_size, TRUE);
|
||||||
|
ok(ret, "Got error %u.\n", GetLastError());
|
||||||
|
ok(ret_size == 5, "Got size %u.\n", ret_size);
|
||||||
|
ok(!memcmp(recv_body, "ping", 5), "Entity body didn't match.\n");
|
||||||
|
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), NULL, &ovl);
|
||||||
|
ok(ret == ERROR_HANDLE_EOF, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
send_response_v1(queue, req->RequestId, s);
|
||||||
|
|
||||||
|
ret = send(s, post_req, sizeof(post_req), 0);
|
||||||
|
ok(ret == sizeof(post_req), "send() returned %d.\n", ret);
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
ret = HttpReceiveHttpRequest(queue, HTTP_NULL_ID, HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY,
|
||||||
|
(HTTP_REQUEST *)req, sizeof(req_buffer), &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), NULL, &ovl);
|
||||||
|
ok(ret == ERROR_HANDLE_EOF, "Got error %u.\n", ret);
|
||||||
|
|
||||||
|
send_response_v1(queue, req->RequestId, s);
|
||||||
|
|
||||||
|
ret = send(s, post_req2, strlen(post_req2), 0);
|
||||||
|
ok(ret == strlen(post_req2), "send() returned %d.\n", ret);
|
||||||
|
ret = send(s, req_body, sizeof(req_body), 0);
|
||||||
|
ok(ret == sizeof(req_body), "send() returned %d.\n", ret);
|
||||||
|
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
ret = HttpReceiveHttpRequest(queue, HTTP_NULL_ID, HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY,
|
||||||
|
(HTTP_REQUEST *)req, 2000, &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
ok(ret_size == 2000, "Got size %u.\n", ret_size);
|
||||||
|
ok(req->Flags == HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS, "Got flags %#x.\n", req->Flags);
|
||||||
|
chunk_size = req->pEntityChunks[0].FromMemory.BufferLength;
|
||||||
|
|
||||||
|
memset(recv_body, 0xcc, sizeof(recv_body));
|
||||||
|
ret_size = 0xdeadbeef;
|
||||||
|
ret = HttpReceiveRequestEntityBody(queue, req->RequestId, 0, recv_body, sizeof(recv_body), &ret_size, NULL);
|
||||||
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
|
ok(ret_size == 2048 - chunk_size, "Got size %u.\n", ret_size);
|
||||||
|
ok(!memcmp(recv_body, req_body + chunk_size, ret_size), "Entity body didn't match.\n");
|
||||||
|
|
||||||
|
send_response_v1(queue, req->RequestId, s);
|
||||||
|
|
||||||
|
CloseHandle(ovl.hEvent);
|
||||||
ret = HttpRemoveUrl(queue, localhost_urlW);
|
ret = HttpRemoveUrl(queue, localhost_urlW);
|
||||||
ok(!ret, "Got error %u.\n", ret);
|
ok(!ret, "Got error %u.\n", ret);
|
||||||
closesocket(s);
|
closesocket(s);
|
||||||
|
|
|
@ -46,6 +46,8 @@ typedef struct _HTTPAPI_VERSION
|
||||||
#define HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY 0x00000001
|
#define HTTP_RECEIVE_REQUEST_FLAG_COPY_BODY 0x00000001
|
||||||
#define HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY 0x00000002
|
#define HTTP_RECEIVE_REQUEST_FLAG_FLUSH_BODY 0x00000002
|
||||||
|
|
||||||
|
#define HTTP_RECEIVE_REQUEST_ENTITY_BODY_FLAG_FILL_BUFFER 0x00000001
|
||||||
|
|
||||||
#define HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS 0x00000001
|
#define HTTP_REQUEST_FLAG_MORE_ENTITY_BODY_EXISTS 0x00000001
|
||||||
#define HTTP_REQUEST_FLAG_IP_ROUTED 0x00000002
|
#define HTTP_REQUEST_FLAG_IP_ROUTED 0x00000002
|
||||||
#define HTTP_REQUEST_FLAG_HTTP2 0x00000004
|
#define HTTP_REQUEST_FLAG_HTTP2 0x00000004
|
||||||
|
|
Loading…
Reference in New Issue