AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
LibcurlHTTP2Request.h
Go to the documentation of this file.
1 /*
2  * Copyright 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 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_LIBCURLHTTP2REQUEST_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_LIBCURLHTTP2REQUEST_H_
18 
19 #include <atomic>
20 #include <chrono>
21 #include <memory>
22 
25 
26 #include "CurlEasyHandleWrapper.h"
28 
29 namespace alexaClientSDK {
30 namespace avsCommon {
31 namespace utils {
32 namespace libcurlUtils {
33 
35 public:
46  const std::shared_ptr<LibcurlSetCurlOptionsCallbackInterface>& setCurlOptionsCallback,
47  std::string id = "");
48 
51  bool cancel() override;
52  std::string getId() const override;
54 
60  CURL* getCurlHandle();
61 
69 
74  void reportResponseCode();
75 
81  bool hasProgressTimedOut() const;
82 
88  bool isIntermittentTransferExpected() const;
89 
93  inline void setTimeOfLastTransfer();
94 
98  void unPause();
99 
105  bool isPaused() const;
106 
112  bool isCancelled() const;
113 
114 private:
128  static size_t writeCallback(char* data, size_t size, size_t nmemb, void* userData);
129 
141  static size_t headerCallback(char* data, size_t size, size_t nmemb, void* userData);
142 
156  static size_t readCallback(char* data, size_t size, size_t nmemb, void* userData);
157 
163  long getResponseCode();
164 
166  std::shared_ptr<http2::HTTP2RequestSourceInterface> m_source;
167 
169  std::shared_ptr<http2::HTTP2ResponseSinkInterface> m_sink;
170 
172  bool m_responseCodeReported;
173 
175  std::chrono::milliseconds m_activityTimeout;
176 
178  std::chrono::steady_clock::time_point m_timeOfLastTransfer;
179 
181  CurlEasyHandleWrapper m_stream;
182 
185  bool m_isIntermittentTransferExpected;
186 
188  bool m_isPaused;
189 
191  std::atomic_bool m_isCancelled;
192 
194  std::chrono::milliseconds m_connectTimeout;
195 };
196 
198  m_timeOfLastTransfer = std::chrono::steady_clock::now();
199 }
200 
201 } // namespace libcurlUtils
202 } // namespace utils
203 } // namespace avsCommon
204 } // namespace alexaClientSDK
205 
206 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_LIBCURLUTILS_LIBCURLHTTP2REQUEST_H_
LibcurlHTTP2Request(const alexaClientSDK::avsCommon::utils::http2::HTTP2RequestConfig &config, const std::shared_ptr< LibcurlSetCurlOptionsCallbackInterface > &setCurlOptionsCallback, std::string id="")
::std::string string
Definition: gtest-port.h:1097
void setTimeOfLastTransfer()
Definition: LibcurlHTTP2Request.h:197
HTTP2ResponseFinishedStatus
Definition: HTTP2ResponseFinishedStatus.h:29
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void reportCompletion(http2::HTTP2ResponseFinishedStatus status)

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0