Commit 6e974615 authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

wininet: Allow to set INTERNET_OPTION_HTTP_DECODING on sessions and connections.

parent cd2d8098
......@@ -2343,11 +2343,6 @@ static DWORD HTTPREQ_SetOption(object_header_t *hdr, DWORD option, void *buffer,
if (!(req->session->appInfo->proxyPassword = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY;
return ERROR_SUCCESS;
case INTERNET_OPTION_HTTP_DECODING:
if(size != sizeof(BOOL))
return ERROR_INVALID_PARAMETER;
req->decoding = *(BOOL*)buffer;
return ERROR_SUCCESS;
}
return INET_SetOption(hdr, option, buffer, size);
......@@ -2917,7 +2912,7 @@ static DWORD set_content_length(http_request_t *request)
request->contentLength = ~0u;
}
if(request->decoding) {
if(request->hdr.decoding) {
int encoding_idx;
static const WCHAR deflateW[] = {'d','e','f','l','a','t','e',0};
......@@ -3303,6 +3298,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
request->hdr.htype = WH_HHTTPREQ;
request->hdr.dwFlags = dwFlags;
request->hdr.dwContext = dwContext;
request->hdr.decoding = session->hdr.decoding;
request->contentLength = ~0u;
request->netconn_stream.data_stream.vtbl = &netconn_stream_vtbl;
......@@ -5803,6 +5799,7 @@ DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
session->hdr.dwFlags = dwFlags;
session->hdr.dwContext = dwContext;
session->hdr.dwInternalFlags |= dwInternalFlags;
session->hdr.decoding = hIC->hdr.decoding;
WININET_AddRef( &hIC->hdr );
session->appInfo = hIC;
......
......@@ -2865,9 +2865,18 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n");
break;
case INTERNET_OPTION_HTTP_DECODING:
FIXME("INTERNET_OPTION_HTTP_DECODING; STUB\n");
SetLastError(ERROR_INTERNET_INVALID_OPTION);
ret = FALSE;
if (!lpwhh)
{
SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
}
if (!lpBuffer || dwBufferLength != sizeof(BOOL))
{
SetLastError(ERROR_INVALID_PARAMETER);
ret = FALSE;
}
else
lpwhh->decoding = *(BOOL *)lpBuffer;
break;
case INTERNET_OPTION_COOKIES_3RD_PARTY:
FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n");
......
......@@ -281,6 +281,7 @@ struct _object_header_t
ULONG ErrorMask;
DWORD dwInternalFlags;
LONG refs;
BOOL decoding;
INTERNET_STATUS_CALLBACK lpfnStatusCB;
struct list entry;
struct list children;
......@@ -377,7 +378,6 @@ typedef struct
DWORD read_size; /* valid data size in read_buf */
BYTE read_buf[READ_BUFFER_SIZE]; /* buffer for already read but not returned data */
BOOL decoding;
data_stream_t *data_stream;
netconn_stream_t netconn_stream;
} http_request_t;
......
......@@ -3696,6 +3696,68 @@ static void test_cache_read_gzipped(int port)
InternetCloseHandle(con);
InternetCloseHandle(ses);
/* Decompression doesn't work while reading from cache */
test_cache_gzip = 0;
sprintf(cache_url, cache_url_fmt, port, get_gzip);
DeleteUrlCacheEntryA(cache_url);
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
ret = TRUE;
ret = InternetSetOptionA(ses, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
size += read;
ok(size == 10, "read %d bytes of data\n", size);
buf[size] = 0;
ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
/* Decompression doesn't work while reading from cache */
test_cache_gzip = 0;
sprintf(cache_url, cache_url_fmt, port, get_gzip);
DeleteUrlCacheEntryA(cache_url);
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
ok(ses != NULL,"InternetOpen failed with error %u\n", GetLastError());
con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed with error %u\n", GetLastError());
ret = TRUE;
ret = InternetSetOptionA(con, INTERNET_OPTION_HTTP_DECODING, &ret, sizeof(ret));
ok(ret, "InternetSetOption(INTERNET_OPTION_HTTP_DECODING) failed: %d\n", GetLastError());
req = HttpOpenRequestA(con, NULL, get_gzip, NULL, NULL, NULL, 0, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequestA(req, "Accept-Encoding: gzip", -1, NULL, 0);
ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
size = 0;
while(InternetReadFile(req, buf+size, sizeof(buf)-1-size, &read) && read)
size += read;
ok(size == 10, "read %d bytes of data\n", size);
buf[size] = 0;
ok(!strncmp(buf, content, size), "incorrect page content: %s\n", buf);
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
DeleteUrlCacheEntryA(cache_url);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment