wininet: Added 204 No Content response tests.

This commit is contained in:
Jacek Caban 2011-05-13 13:49:00 +02:00 committed by Alexandre Julliard
parent 188de03497
commit 5a5eddfe81
1 changed files with 63 additions and 0 deletions

View File

@ -1760,6 +1760,11 @@ static DWORD CALLBACK server_thread(LPVOID param)
else
send(c, notokmsg, sizeof notokmsg-1, 0);
}
if (strstr(buffer, "GET /test_no_content"))
{
static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n";
send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0);
}
shutdown(c, 2);
closesocket(c);
@ -2112,6 +2117,63 @@ static void test_http1_1(int port)
InternetCloseHandle(ses);
}
static void test_no_content(int port)
{
HINTERNET session, connection, req;
DWORD res;
trace("Testing 204 no content response...\n");
hCompleteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
session = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);
ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError());
pInternetSetStatusCallbackA(session, callback);
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
connection = InternetConnectA(session, "localhost", port,
NULL, NULL, INTERNET_SERVICE_HTTP, 0x0, 0xdeadbeef);
ok(connection != NULL,"InternetConnect failed with error %u\n", GetLastError());
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED);
req = HttpOpenRequestA(connection, "GET", "/test_no_content", NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_RESYNCHRONIZE, 0xdeadbead);
ok(req != NULL, "HttpOpenRequest failed: %u\n", GetLastError());
CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED);
SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT);
SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER);
SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST);
SET_EXPECT(INTERNET_STATUS_REQUEST_SENT);
SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE);
SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED);
SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION);
SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED);
SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE);
res = HttpSendRequestA(req, NULL, -1, NULL, 0);
ok(!res && (GetLastError() == ERROR_IO_PENDING),
"Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n");
WaitForSingleObject(hCompleteEvent, INFINITE);
CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER);
CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER);
CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT);
CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE);
CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION);
CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE);
close_async_handle(session, hCompleteEvent, 2);
CloseHandle(hCompleteEvent);
}
static void test_HttpSendRequestW(int port)
{
static const WCHAR header[] = {'U','A','-','C','P','U',':',' ','x','8','6',0};
@ -2645,6 +2707,7 @@ static void test_http_connection(void)
test_last_error(si.port);
test_options(si.port);
test_url_caching(si.port, &si.num_testH_retrievals);
test_no_content(si.port);
/* send the basic request again to shutdown the server thread */
test_basic_request(si.port, "GET", "/quit");