AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MimeResponseSink.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_ACL_INCLUDE_ACL_TRANSPORT_MIMERESPONSESINK_H_
17 #define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MIMERESPONSESINK_H_
18 
19 #include <memory>
20 
24 
27 
28 namespace alexaClientSDK {
29 namespace acl {
30 
38 public:
48  std::shared_ptr<MimeResponseStatusHandlerInterface> handler,
49  std::shared_ptr<MessageConsumerInterface> messageConsumer,
50  std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
51  std::string attachmentContextId);
52 
56  virtual ~MimeResponseSink() = default;
57 
60  bool onReceiveResponseCode(long responseCode) override;
61  bool onReceiveHeaderLine(const std::string& line) override;
62  bool onBeginMimePart(const std::multimap<std::string, std::string>& headers) override;
63  avsCommon::utils::http2::HTTP2ReceiveDataStatus onReceiveMimeData(const char* bytes, size_t size) override;
64  bool onEndMimePart() override;
65  avsCommon::utils::http2::HTTP2ReceiveDataStatus onReceiveNonMimeData(const char* bytes, size_t size) override;
68 
69 private:
71  enum ContentType {
73  NONE,
75  JSON,
77  ATTACHMENT
78  };
79 
87  avsCommon::utils::http2::HTTP2ReceiveDataStatus writeToAttachment(const char* bytes, size_t size);
88 
90  std::shared_ptr<MimeResponseStatusHandlerInterface> m_handler;
91 
93  std::shared_ptr<MessageConsumerInterface> m_messageConsumer;
94 
96  std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> m_attachmentManager;
97 
99  ContentType m_contentType;
100 
102  std::string m_attachmentContextId;
103 
108  std::string m_directiveBeingReceived;
109 
114  std::string m_attachmentIdBeingReceived;
115 
117  std::unique_ptr<avsCommon::avs::attachment::AttachmentWriter> m_attachmentWriter;
118 
120  std::string m_nonMimeBody;
121 };
122 
123 } // namespace acl
124 } // namespace alexaClientSDK
125 
126 #endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MIMERESPONSESINK_H_
bool onReceiveHeaderLine(const std::string &line) override
MimeResponseSink(std::shared_ptr< MimeResponseStatusHandlerInterface > handler, std::shared_ptr< MessageConsumerInterface > messageConsumer, std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > attachmentManager, std::string attachmentContextId)
::std::string string
Definition: gtest-port.h:1097
HTTP2ResponseFinishedStatus
Definition: HTTP2ResponseFinishedStatus.h:29
avsCommon::utils::http2::HTTP2ReceiveDataStatus onReceiveNonMimeData(const char *bytes, size_t size) override
void onResponseFinished(avsCommon::utils::http2::HTTP2ResponseFinishedStatus status) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool onBeginMimePart(const std::multimap< std::string, std::string > &headers) override
avsCommon::utils::http2::HTTP2ReceiveDataStatus onReceiveMimeData(const char *bytes, size_t size) override
Definition: MimeResponseSink.h:37
HTTP2ReceiveDataStatus
Definition: HTTP2ReceiveDataStatus.h:28
bool onReceiveResponseCode(long responseCode) override

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