http_downloader_winhttp.h (1067B)
1 // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com> 2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) 3 4 #pragma once 5 #include "http_downloader.h" 6 7 #include "common/windows_headers.h" 8 9 #include <winhttp.h> 10 11 class HTTPDownloaderWinHttp final : public HTTPDownloader 12 { 13 public: 14 HTTPDownloaderWinHttp(); 15 ~HTTPDownloaderWinHttp() override; 16 17 bool Initialize(std::string user_agent); 18 19 protected: 20 Request* InternalCreateRequest() override; 21 void InternalPollRequests() override; 22 bool StartRequest(HTTPDownloader::Request* request) override; 23 void CloseRequest(HTTPDownloader::Request* request) override; 24 25 private: 26 struct Request : HTTPDownloader::Request 27 { 28 std::wstring object_name; 29 HINTERNET hConnection = NULL; 30 HINTERNET hRequest = NULL; 31 u32 io_position = 0; 32 }; 33 34 static void CALLBACK HTTPStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, 35 LPVOID lpvStatusInformation, DWORD dwStatusInformationLength); 36 37 HINTERNET m_hSession = NULL; 38 };