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, ...@@ -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; if (!(req->session->appInfo->proxyPassword = heap_strdupW(buffer))) return ERROR_OUTOFMEMORY;
return ERROR_SUCCESS; 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); return INET_SetOption(hdr, option, buffer, size);
...@@ -2917,7 +2912,7 @@ static DWORD set_content_length(http_request_t *request) ...@@ -2917,7 +2912,7 @@ static DWORD set_content_length(http_request_t *request)
request->contentLength = ~0u; request->contentLength = ~0u;
} }
if(request->decoding) { if(request->hdr.decoding) {
int encoding_idx; int encoding_idx;
static const WCHAR deflateW[] = {'d','e','f','l','a','t','e',0}; static const WCHAR deflateW[] = {'d','e','f','l','a','t','e',0};
...@@ -3303,6 +3298,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session, ...@@ -3303,6 +3298,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
request->hdr.htype = WH_HHTTPREQ; request->hdr.htype = WH_HHTTPREQ;
request->hdr.dwFlags = dwFlags; request->hdr.dwFlags = dwFlags;
request->hdr.dwContext = dwContext; request->hdr.dwContext = dwContext;
request->hdr.decoding = session->hdr.decoding;
request->contentLength = ~0u; request->contentLength = ~0u;
request->netconn_stream.data_stream.vtbl = &netconn_stream_vtbl; request->netconn_stream.data_stream.vtbl = &netconn_stream_vtbl;
...@@ -5803,6 +5799,7 @@ DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName, ...@@ -5803,6 +5799,7 @@ DWORD HTTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
session->hdr.dwFlags = dwFlags; session->hdr.dwFlags = dwFlags;
session->hdr.dwContext = dwContext; session->hdr.dwContext = dwContext;
session->hdr.dwInternalFlags |= dwInternalFlags; session->hdr.dwInternalFlags |= dwInternalFlags;
session->hdr.decoding = hIC->hdr.decoding;
WININET_AddRef( &hIC->hdr ); WININET_AddRef( &hIC->hdr );
session->appInfo = hIC; session->appInfo = hIC;
......
...@@ -2865,9 +2865,18 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, ...@@ -2865,9 +2865,18 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n"); FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n");
break; break;
case INTERNET_OPTION_HTTP_DECODING: case INTERNET_OPTION_HTTP_DECODING:
FIXME("INTERNET_OPTION_HTTP_DECODING; STUB\n"); if (!lpwhh)
SetLastError(ERROR_INTERNET_INVALID_OPTION); {
ret = FALSE; 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; break;
case INTERNET_OPTION_COOKIES_3RD_PARTY: case INTERNET_OPTION_COOKIES_3RD_PARTY:
FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n"); FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n");
......
...@@ -281,6 +281,7 @@ struct _object_header_t ...@@ -281,6 +281,7 @@ struct _object_header_t
ULONG ErrorMask; ULONG ErrorMask;
DWORD dwInternalFlags; DWORD dwInternalFlags;
LONG refs; LONG refs;
BOOL decoding;
INTERNET_STATUS_CALLBACK lpfnStatusCB; INTERNET_STATUS_CALLBACK lpfnStatusCB;
struct list entry; struct list entry;
struct list children; struct list children;
...@@ -377,7 +378,6 @@ typedef struct ...@@ -377,7 +378,6 @@ typedef struct
DWORD read_size; /* valid data size in read_buf */ DWORD read_size; /* valid data size in read_buf */
BYTE read_buf[READ_BUFFER_SIZE]; /* buffer for already read but not returned data */ BYTE read_buf[READ_BUFFER_SIZE]; /* buffer for already read but not returned data */
BOOL decoding;
data_stream_t *data_stream; data_stream_t *data_stream;
netconn_stream_t netconn_stream; netconn_stream_t netconn_stream;
} http_request_t; } http_request_t;
......
...@@ -3696,6 +3696,68 @@ static void test_cache_read_gzipped(int port) ...@@ -3696,6 +3696,68 @@ static void test_cache_read_gzipped(int port)
InternetCloseHandle(con); InternetCloseHandle(con);
InternetCloseHandle(ses); 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); 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