AWS SDK for C++  0.14.3
AWS SDK for C++
WinSyncHttpClient.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <aws/core/Core_EXPORTS.h>
19 
20 #include <aws/core/utils/memory/stl/AwsStringStream.h>
24 
25 namespace Aws
26 {
27  namespace Client
28  {
29  struct ClientConfiguration;
30  } // namespace Client
31 
32  namespace Http
33  {
34 
35  class WinConnectionPoolMgr;
36 
41  {
42  public:
43  using Base = HttpClient;
44 
45  virtual ~WinSyncHttpClient();
46 
50  std::shared_ptr<HttpResponse> MakeRequest(HttpRequest& request,
51  Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr,
52  Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) const;
53 
57  virtual const char* GetLogTag() const { return "WinSyncHttpClient"; }
58  protected:
62  void SetOpenHandle(void* handle);
66  void* GetOpenHandle() const { return m_openHandle; }
70  void SetConnectionPoolManager(WinConnectionPoolMgr* connectionMgr);
74  WinConnectionPoolMgr* GetConnectionPoolManager() const { return m_connectionPoolMgr; }
78  void* AllocateWindowsHttpRequest(const Aws::Http::HttpRequest& request, void* connection) const;
83  private:
84 
85  virtual void* OpenRequest(const Aws::Http::HttpRequest& request, void* connection, const Aws::StringStream& ss) const = 0;
86  virtual void DoAddHeaders(void* hHttpRequest, Aws::String& headerStr) const = 0;
87  virtual uint64_t DoWriteData(void* hHttpRequest, char* streamBuffer, uint64_t bytesRead) const = 0;
88  virtual bool DoReceiveResponse(void* hHttpRequest) const = 0;
89  virtual bool DoQueryHeaders(void* hHttpRequest, std::shared_ptr<Aws::Http::Standard::StandardHttpResponse>& response, Aws::StringStream& ss, uint64_t& read) const = 0;
90  virtual bool DoSendRequest(void* hHttpRequest) const = 0;
91  virtual bool DoReadData(void* hHttpRequest, char* body, uint64_t size, uint64_t& read) const = 0;
92  virtual void* GetClientModule() const = 0;
93 
94  bool StreamPayloadToRequest(const HttpRequest& request, void* hHttpRequest) const;
95  void LogRequestInternalFailure() const;
96  std::shared_ptr<HttpResponse> BuildSuccessResponse(const Aws::Http::HttpRequest& request, void* hHttpRequest, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter) const;
97  void AddHeadersToRequest(const HttpRequest& request, void* hHttpRequest) const;
98 
99  void* m_openHandle;
100  //we need control over the order in which this gets cleaned up
101  //that's why I'm not using unique_ptr here.
102  WinConnectionPoolMgr* m_connectionPoolMgr;
103  };
104 
105  } // namespace Http
106 } // namespace Aws
107 
WinConnectionPoolMgr * GetConnectionPoolManager() const
virtual const char * GetLogTag() const
std::basic_stringstream< char, std::char_traits< char >, Aws::Allocator< char > > StringStream
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
#define AWS_CORE_API
Definition: Core_EXPORTS.h:35
JSON (JavaScript Object Notation).