AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
ResponseSink.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 ACSDKASSETSCOMMON_RESPONSESINK_H_
17 #define ACSDKASSETSCOMMON_RESPONSESINK_H_
18 #include <fstream>
19 #include <memory>
20 
21 #include "DownloadChunkQueue.h"
22 #include "DownloadStream.h"
25 
26 namespace alexaClientSDK {
27 namespace acsdkAssets {
28 namespace common {
29 
34 class ResponseSink {
35 public:
40  ResponseSink(const std::shared_ptr<commonInterfaces::DavsRequest>& request, const std::string& workingDirectory);
41 
45  virtual ~ResponseSink() = default;
46 
51  std::shared_ptr<commonInterfaces::VendableArtifact> getArtifact();
52 
58 
65  bool onHeader(const std::string& header);
66 
73  bool parser(std::shared_ptr<DownloadChunkQueue>& downloadChunkQueue);
74 
75 private:
80  void setContentType(const std::string& type);
87  void setData(const char* buffer, size_t size);
92  void endData();
93 
94 private:
96  enum class ContentType {
98  NONE,
100  JSON,
102  ATTACHMENT
103  };
104 
106  ContentType m_contentType;
107 
109  std::string m_jsonString;
110 
112  std::shared_ptr<DownloadStream> m_attachment;
113 
115  const std::string m_parentDirectory;
116 
118  std::string m_artifactPath;
119 
121  std::shared_ptr<commonInterfaces::DavsRequest> m_request;
122 
124  std::shared_ptr<commonInterfaces::VendableArtifact> m_artifact;
125 
127  std::string m_boundary;
128 };
129 
130 } // namespace common
131 } // namespace acsdkAssets
132 } // namespace alexaClientSDK
133 
134 #endif // ACSDKASSETSCOMMON_RESPONSESINK_H_
bool parser(std::shared_ptr< DownloadChunkQueue > &downloadChunkQueue)
::std::string string
Definition: gtest-port.h:1097
ResponseSink(const std::shared_ptr< commonInterfaces::DavsRequest > &request, const std::string &workingDirectory)
bool onHeader(const std::string &header)
Definition: common.py:1
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
type
Definition: upload.py:443
std::shared_ptr< commonInterfaces::VendableArtifact > getArtifact()

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