AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
HTTP2MimeResponseDecoder.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_HTTP2_HTTP2MIMERESPONSEDECODER_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_HTTP2_HTTP2MIMERESPONSEDECODER_H_
18 
19 #include <memory>
20 
21 #include <MultipartParser/MultipartReader.h>
22 
25 
26 namespace alexaClientSDK {
27 namespace avsCommon {
28 namespace utils {
29 namespace http2 {
30 
36 public:
42  HTTP2MimeResponseDecoder(std::shared_ptr<HTTP2MimeResponseSinkInterface> sink);
43 
47  ~HTTP2MimeResponseDecoder() = default;
48 
51  bool onReceiveResponseCode(long responseCode) override;
52  bool onReceiveHeaderLine(const std::string& line) override;
53  HTTP2ReceiveDataStatus onReceiveData(const char* bytes, size_t size) override;
54  void onResponseFinished(HTTP2ResponseFinishedStatus status) override;
56 
57 private:
59  static void partBeginCallback(const MultipartHeaders& headers, void* userData);
60  static void partDataCallback(const char* buffer, size_t size, void* userData);
61  static void partEndCallback(void* userData);
62 
64  std::shared_ptr<HTTP2MimeResponseSinkInterface> m_sink;
66  long m_responseCode;
68  MultipartReader m_multipartReader;
70  HTTP2ReceiveDataStatus m_lastStatus;
72  size_t m_index;
74  size_t m_leadingCRLFCharsLeftToRemove;
76  bool m_boundaryFound;
78  size_t m_lastSuccessIndex;
79 };
80 
81 } // namespace http2
82 } // namespace utils
83 } // namespace avsCommon
84 } // namespace alexaClientSDK
85 
86 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_HTTP2_HTTP2MIMERESPONSEDECODER_H_
::std::string string
Definition: gtest-port.h:1097
HTTP2ReceiveDataStatus onReceiveData(const char *bytes, size_t size) override
void onResponseFinished(HTTP2ResponseFinishedStatus status) override
HTTP2ResponseFinishedStatus
Definition: HTTP2ResponseFinishedStatus.h:29
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool onReceiveHeaderLine(const std::string &line) override
HTTP2ReceiveDataStatus
Definition: HTTP2ReceiveDataStatus.h:28
HTTP2MimeResponseDecoder(std::shared_ptr< HTTP2MimeResponseSinkInterface > sink)

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