17 #if defined(AZ_PLATFORM_WINDOWS)
18 #if !defined(WIN32_LEAN_AND_MEAN)
19 #define WIN32_LEAN_AND_MEAN
21 #if !defined(NOMINMAX)
27 #include <type_traits>
31 namespace Azure {
namespace Core {
namespace Http {
35 constexpr
static size_t DefaultUploadChunkSize = 1024 * 64;
36 constexpr
static size_t MaximumUploadChunkSize = 1024 * 1024;
38 struct HandleManager final
40 Context
const& m_context;
42 HINTERNET m_connectionHandle;
43 HINTERNET m_requestHandle;
45 HandleManager(Request& request, Context
const& context)
46 : m_request(request), m_context(context)
48 m_connectionHandle = NULL;
49 m_requestHandle = NULL;
58 WinHttpCloseHandle(m_requestHandle);
59 m_requestHandle = NULL;
62 if (m_connectionHandle)
64 WinHttpCloseHandle(m_connectionHandle);
65 m_connectionHandle = NULL;
72 std::unique_ptr<HandleManager> m_handleManager;
86 int64_t m_contentLength;
88 int64_t m_streamTotalRead;
102 WinHttpStream(std::unique_ptr<HandleManager> handleManager, int64_t contentLength)
103 : m_handleManager(std::move(handleManager)), m_contentLength(contentLength),
104 m_isEOF(false), m_streamTotalRead(0)
113 int64_t
Length()
const override {
return this->m_contentLength; }
139 HINTERNET m_sessionHandle = NULL;
141 HINTERNET CreateSessionHandle();
142 void CreateConnectionHandle(std::unique_ptr<_detail::HandleManager>& handleManager);
143 void CreateRequestHandle(std::unique_ptr<_detail::HandleManager>& handleManager);
144 void Upload(std::unique_ptr<_detail::HandleManager>& handleManager);
145 void SendRequest(std::unique_ptr<_detail::HandleManager>& handleManager);
146 void ReceiveResponse(std::unique_ptr<_detail::HandleManager>& handleManager);
147 int64_t GetContentLength(
148 std::unique_ptr<_detail::HandleManager>& handleManager,
151 std::unique_ptr<RawResponse> SendRequestAndGetResponse(
152 std::unique_ptr<_detail::HandleManager> handleManager,
171 virtual std::unique_ptr<RawResponse>
Send(
Request& request,
Context const& context)
override;
179 WinHttpCloseHandle(m_sessionHandle);
180 m_sessionHandle = NULL;