16#if !defined(WIN32_LEAN_AND_MEAN) 
   17#define WIN32_LEAN_AND_MEAN 
   28#pragma warning(disable : 6553) 
   29#pragma warning(disable : 6387)  
   33#include <wil\resource.h> 
   37namespace Azure { 
namespace Core { 
namespace Http { 
namespace _detail {
 
   48  class WinHttpAction final {
 
   51    WinHttpRequest* 
const m_httpRequest{};
 
   52    wil::unique_event m_actionCompleteEvent;
 
   54    std::mutex m_actionCompleteMutex;
 
   55    DWORD m_expectedStatus{};
 
   56    DWORD m_stowedError{};
 
   57    DWORD_PTR m_stowedErrorInformation{};
 
   58    DWORD m_bytesAvailable{};
 
   64    static void CALLBACK StatusCallback(
 
   67        DWORD dwInternetStatus,
 
   68        LPVOID lpvStatusInformation,
 
   69        DWORD dwStatusInformationLength);
 
   75    void OnHttpStatusOperation(
 
   78        LPVOID statusInformation,
 
   79        DWORD statusInformationLength);
 
   87    WinHttpAction(WinHttpRequest* request)
 
   89        : m_httpRequest(request), m_actionCompleteEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr))
 
   91      if (!m_actionCompleteEvent)
 
   93        throw std::runtime_error(
"Error creating Action Complete Event.");
 
  103    bool RegisterWinHttpStatusCallback(
 
  104        Azure::Core::_internal::UniqueHandle<HINTERNET> 
const& internetHandle);
 
  127        std::function<
void()> initiateAction,
 
  128        DWORD expectedCallbackStatus,
 
  130        Azure::DateTime::duration 
const& pollDuration = std::chrono::milliseconds(800));
 
  135    void CompleteAction();
 
  141    void CompleteActionWithData(DWORD bytesAvailable);
 
  147    void CompleteActionWithError(DWORD_PTR stowedErrorInformation, DWORD stowedError);
 
  148    DWORD GetStowedError();
 
  149    DWORD_PTR GetStowedErrorInformation();
 
  150    DWORD GetBytesAvailable();
 
  156  class WinHttpRequest final {
 
  157    bool m_requestHandleClosed{
false};
 
  158    Azure::Core::_internal::UniqueHandle<HINTERNET> m_requestHandle;
 
  159    std::unique_ptr<WinHttpAction> m_httpAction;
 
  160    std::vector<std::string> m_expectedTlsRootCertificates;
 
  161    wil::unique_cert_context m_tlsClientCertificate;
 
  166    bool AddCertificatesToStore(
 
  167        std::vector<std::string> 
const& trustedCertificates,
 
  168        HCERTSTORE 
const hCertStore) 
const;
 
  172    bool VerifyCertificatesInChain(
 
  173        std::vector<std::string> 
const& trustedCertificates,
 
  178        Azure::Core::_internal::UniqueHandle<HINTERNET> 
const& connectionHandle,
 
  182        WinHttpTransportOptions 
const& options);
 
  185    void MarkRequestHandleClosed() { m_requestHandleClosed = 
true; };
 
  189    int64_t GetContentLength(HttpMethod requestMethod, HttpStatusCode responseStatusCode);
 
  190    std::unique_ptr<RawResponse> SendRequestAndGetResponse(HttpMethod requestMethod);
 
  192    void EnableWebSocketsSupport();
 
  193    void HandleExpectedTlsRootCertificates(HINTERNET hInternet);
 
  198    std::unique_ptr<_detail::WinHttpRequest> m_requestHandle;
 
  212    int64_t m_contentLength;
 
  214    int64_t m_streamTotalRead;
 
  228    WinHttpStream(std::unique_ptr<_detail::WinHttpRequest>& requestHandle, int64_t contentLength)
 
  229        : m_requestHandle(std::move(requestHandle)), m_contentLength(contentLength), m_isEOF(false),
 
  239    int64_t 
Length()
 const override { 
return this->m_contentLength; }
 
A context is a node within a unidirectional tree that represents deadlines and key/value pairs.
Definition context.hpp:72
The method to be performed on the resource identified by the Request.
Definition http.hpp:95
A request message from a client to a server.
Definition http.hpp:183
Used to read data to/from a service.
Definition body_stream.hpp:32
virtual int64_t Length() const =0
Get the length of the data.
Represents the location where a request will be performed.
Definition url.hpp:46
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
Uniform Resource Locator (URL).
Azure::Core::Http::HttpTransport implementation via WinHTTP.
const struct _CERT_CONTEXT * PCCERT_CONTEXT
Declaration of a Windows PCCERT_CONTEXT structure from the Windows SDK.
Definition win_http_transport.hpp:28