Skip to content

Commit

Permalink
Support gzip or deflate encoded responses
Browse files Browse the repository at this point in the history
  • Loading branch information
vslavik committed May 7, 2024
1 parent f2e0b4c commit abc7f80
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#ifndef HTTP_PROTOCOL_FLAG_HTTP2
#define HTTP_PROTOCOL_FLAG_HTTP2 0x2
#endif
#ifndef INTERNET_OPTION_HTTP_DECODING
#define INTERNET_OPTION_HTTP_DECODING 65
#endif


namespace winsparkle
Expand Down Expand Up @@ -188,8 +191,9 @@ void WaitUntilSignaledWithTerminationCheck(Event& event, Thread *thread)
public functions
*--------------------------------------------------------------------------*/

void DownloadFile(const std::string& url, IDownloadSink *sink, Thread *onThread, const std::string &headers, int flags)
void DownloadFile(const std::string& url, IDownloadSink* sink, Thread* onThread, const std::string& headers_, int flags)
{
std::string headers = headers_;
char url_path[2048];
URL_COMPONENTSA urlc;
memset(&urlc, 0, sizeof(urlc));
Expand All @@ -214,6 +218,13 @@ void DownloadFile(const std::string& url, IDownloadSink *sink, Thread *onThread,
DWORD dwOption = HTTP_PROTOCOL_FLAG_HTTP2;
InternetSetOptionW(inet, INTERNET_OPTION_ENABLE_HTTP_PROTOCOL, &dwOption, sizeof(dwOption));

if (IsWindowsVistaOrGreater())
{
DWORD dwEnableHttpDecoding = TRUE;
InternetSetOptionW(inet, INTERNET_OPTION_HTTP_DECODING, &dwEnableHttpDecoding, sizeof(dwEnableHttpDecoding));
headers += "Accept-Encoding: gzip, deflate\r\n";
}

// Never allow local caching, always contact the server for both
// appcast feeds and downloads. This is useful in case of
// misconfigured servers.
Expand Down

0 comments on commit abc7f80

Please sign in to comment.