AWS SDK for C++  0.12.9
AWS SDK for C++
CurlHttpClient.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2015 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 
17 #pragma once
18 
19 #include <aws/core/Core_EXPORTS.h>
24 #include <atomic>
25 
26 namespace Aws
27 {
28 namespace Http
29 {
30 
31 
32 //Curl implementation of an http client. Right now it is only synchronous.
34 {
35 public:
36 
37  using Base = HttpClient;
38 
39  //Creates client, initializes curl handle if it hasn't been created already.
41  //Makes request and receives response synchronously
42  std::shared_ptr<HttpResponse> MakeRequest(HttpRequest& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr,
43  Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) const;
44 
45  static void InitGlobalState();
46  static void CleanupGlobalState();
47 
48 private:
49  mutable CurlHandleContainer m_curlHandleContainer;
50  bool m_isUsingProxy;
51  Aws::String m_proxyUserName;
52  Aws::String m_proxyPassword;
53  Aws::String m_proxyHost;
54  unsigned m_proxyPort;
55  bool m_verifySSL;
56  Aws::String m_caPath;
57  bool m_allowRedirects;
58 
59  static std::atomic<bool> isInit;
60 
61  //Callback to read the content from the content body of the request
62  static size_t ReadBody(char* ptr, size_t size, size_t nmemb, void* userdata);
63  //callback to write the content from the response to the response object
64  static size_t WriteData(char* ptr, size_t size, size_t nmemb, void* userdata);
65  //callback to write the headers from the response to the response
66  static size_t WriteHeader(char* ptr, size_t size, size_t nmemb, void* userdata);
67 
68 };
69 
71 
72 } // namespace Http
73 } // namespace Aws
74 
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
#define AWS_CORE_API
Definition: Core_EXPORTS.h:30
JSON (JavaScript Object Notation).