AWS IoT Device SDK C++ v2: crt/aws-crt-cpp/include/aws/crt/http/HttpRequestResponse.h Source File

AWS IoT Device SDK C++ v2 1.14.0 AWS IoT Device SDK C++ v2

HttpRequestResponse.h
Go to the documentation of this file.
1#pragma once
7#include <aws/crt/Exports.h>
8#include <aws/crt/Types.h>
9#include <aws/crt/io/Stream.h>
10
11struct aws_http_header;
12struct aws_http_message;
13
14namespace Aws
15{
16 namespace Crt
17 {
18 namespace Mqtt
19 {
20 class MqttConnection;
21 }
22
23 namespace Http
24 {
25 using HttpHeader = aws_http_header;
26
30 class AWS_CRT_CPP_API HttpMessage
31 {
32 public:
33 virtual ~HttpMessage();
34
35 HttpMessage(const HttpMessage &) = delete;
36 HttpMessage(HttpMessage &&) = delete;
37 HttpMessage &operator=(const HttpMessage &) = delete;
38 HttpMessage &operator=(HttpMessage &&) = delete;
39
43 std::shared_ptr<Aws::Crt::Io::InputStream> GetBody() const noexcept;
44
50 bool SetBody(const std::shared_ptr<Aws::Crt::Io::IStream> &body) noexcept;
51
57 bool SetBody(const std::shared_ptr<Aws::Crt::Io::InputStream> &body) noexcept;
58
63 size_t GetHeaderCount() const noexcept;
64
70 Optional<HttpHeader> GetHeader(size_t index) const noexcept;
71
77 bool AddHeader(const HttpHeader &header) noexcept;
78
84 bool EraseHeader(size_t index) noexcept;
85
89 operator bool() const noexcept { return m_message != nullptr; }
90
92 struct aws_http_message *GetUnderlyingMessage() const noexcept { return m_message; }
93
94 protected:
95 HttpMessage(Allocator *allocator, struct aws_http_message *message) noexcept;
96
97 Allocator *m_allocator;
98 struct aws_http_message *m_message;
99 std::shared_ptr<Aws::Crt::Io::InputStream> m_bodyStream;
100 };
101
105 class AWS_CRT_CPP_API HttpRequest : public HttpMessage
106 {
107 friend class Mqtt::MqttConnection;
108
109 public:
110 HttpRequest(Allocator *allocator = g_allocator);
111
115 Optional<ByteCursor> GetMethod() const noexcept;
116
120 bool SetMethod(ByteCursor method) noexcept;
121
125 Optional<ByteCursor> GetPath() const noexcept;
126
130 bool SetPath(ByteCursor path) noexcept;
131
132 protected:
133 HttpRequest(Allocator *allocator, struct aws_http_message *message);
134 };
135
139 class AWS_CRT_CPP_API HttpResponse : public HttpMessage
140 {
141 public:
142 HttpResponse(Allocator *allocator = g_allocator);
143
147 Optional<int> GetResponseCode() const noexcept;
148
152 bool SetResponseCode(int response) noexcept;
153 };
154 } // namespace Http
155 } // namespace Crt
156} // namespace Aws
Stream.h
Types.h
Aws::Crt::Http::HttpMessage
Definition: HttpRequestResponse.h:31
Aws::Crt::Http::HttpMessage::m_bodyStream
std::shared_ptr< Aws::Crt::Io::InputStream > m_bodyStream
Definition: HttpRequestResponse.h:99
Aws::Crt::Http::HttpMessage::HttpMessage
HttpMessage(HttpMessage &&)=delete
Aws::Crt::Http::HttpMessage::operator=
HttpMessage & operator=(HttpMessage &&)=delete
Aws::Crt::Http::HttpMessage::operator=
HttpMessage & operator=(const HttpMessage &)=delete
Aws::Crt::Http::HttpMessage::m_message
struct aws_http_message * m_message
Definition: HttpRequestResponse.h:98
Aws::Crt::Http::HttpMessage::m_allocator
Allocator * m_allocator
Definition: HttpRequestResponse.h:97
Aws::Crt::Http::HttpMessage::HttpMessage
HttpMessage(const HttpMessage &)=delete
Aws::Crt::Http::HttpRequest
Definition: HttpRequestResponse.h:106
Aws::Crt::Http::HttpResponse
Definition: HttpRequestResponse.h:140
Aws::Crt::Mqtt::MqttConnection
Definition: MqttClient.h:131
Aws::Crt::Optional
Definition: Optional.h:17
Exports.h
AWS_CRT_CPP_API
#define AWS_CRT_CPP_API
Definition: Exports.h:37
Aws::Crt::Http::HttpHeader
aws_http_header HttpHeader
Definition: HttpConnection.h:34
Aws::Crt::Io::IStream
std::basic_istream< char, std::char_traits< char > > IStream
Definition: Types.h:37
Aws::Crt::ByteCursor
aws_byte_cursor ByteCursor
Definition: Types.h:33
Aws::Crt::Allocator
aws_allocator Allocator
Definition: StlAllocator.h:17
Aws::Crt::g_allocator
AWS_CRT_CPP_API Allocator * g_allocator
Definition: Api.cpp:21
Aws
Definition: Api.h:17
Aws::index
int index
Definition: cJSON.h:188
std
Definition: StringView.h:851