AWS IoT Device SDK C++ v2 1.44.2
AWS IoT Device SDK C++ v2
Loading...
Searching...
No Matches
HttpRequestResponse.h
Go to the documentation of this file.
1#pragma once
6
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 class MqttConnectionCore;
22 } // namespace Mqtt
23 namespace Mqtt5
24 {
25 class Mqtt5ClientCore;
26 }
27 namespace Http
28 {
29 using HttpHeader = aws_http_header;
30
35 {
36 public:
37 virtual ~HttpMessage();
38
39 HttpMessage(const HttpMessage &) = delete;
41 HttpMessage &operator=(const HttpMessage &) = delete;
43
47 std::shared_ptr<Aws::Crt::Io::InputStream> GetBody() const noexcept;
48
54 bool SetBody(const std::shared_ptr<Aws::Crt::Io::IStream> &body) noexcept;
55
61 bool SetBody(const std::shared_ptr<Aws::Crt::Io::InputStream> &body) noexcept;
62
67 size_t GetHeaderCount() const noexcept;
68
74 Optional<HttpHeader> GetHeader(size_t index) const noexcept;
75
81 bool AddHeader(const HttpHeader &header) noexcept;
82
88 bool EraseHeader(size_t index) noexcept;
89
93 operator bool() const noexcept { return m_message != nullptr; }
94
96 struct aws_http_message *GetUnderlyingMessage() const noexcept { return m_message; }
97
98 protected:
99 HttpMessage(Allocator *allocator, struct aws_http_message *message) noexcept;
100
102 struct aws_http_message *m_message;
103 std::shared_ptr<Aws::Crt::Io::InputStream> m_bodyStream;
104 };
105
110 {
111 friend class Mqtt::MqttConnectionCore;
112 friend class Mqtt5::Mqtt5ClientCore;
113
114 public:
115 HttpRequest(Allocator *allocator = ApiAllocator());
116
120 Optional<ByteCursor> GetMethod() const noexcept;
121
125 bool SetMethod(ByteCursor method) noexcept;
126
130 Optional<ByteCursor> GetPath() const noexcept;
131
135 bool SetPath(ByteCursor path) noexcept;
136
137 protected:
138 HttpRequest(Allocator *allocator, struct aws_http_message *message);
139 };
140
145 {
146 public:
147 HttpResponse(Allocator *allocator = ApiAllocator());
148
152 Optional<int> GetResponseCode() const noexcept;
153
157 bool SetResponseCode(int response) noexcept;
158 };
159 } // namespace Http
160 } // namespace Crt
161} // namespace Aws
size_t GetHeaderCount() const noexcept
Definition HttpRequestResponse.cpp:66
std::shared_ptr< Aws::Crt::Io::InputStream > m_bodyStream
Definition HttpRequestResponse.h:103
HttpMessage(HttpMessage &&)=delete
Optional< HttpHeader > GetHeader(size_t index) const noexcept
Definition HttpRequestResponse.cpp:71
bool SetBody(const std::shared_ptr< Aws::Crt::Io::IStream > &body) noexcept
Definition HttpRequestResponse.cpp:39
bool EraseHeader(size_t index) noexcept
Definition HttpRequestResponse.cpp:87
HttpMessage & operator=(HttpMessage &&)=delete
HttpMessage & operator=(const HttpMessage &)=delete
bool AddHeader(const HttpHeader &header) noexcept
Definition HttpRequestResponse.cpp:82
std::shared_ptr< Aws::Crt::Io::InputStream > GetBody() const noexcept
Definition HttpRequestResponse.cpp:34
struct aws_http_message * m_message
Definition HttpRequestResponse.h:102
Allocator * m_allocator
Definition HttpRequestResponse.h:101
HttpMessage(const HttpMessage &)=delete
Optional< ByteCursor > GetMethod() const noexcept
Definition HttpRequestResponse.cpp:104
HttpRequest(Allocator *allocator=ApiAllocator())
Definition HttpRequestResponse.cpp:92
Optional< ByteCursor > GetPath() const noexcept
Definition HttpRequestResponse.cpp:120
bool SetPath(ByteCursor path) noexcept
Definition HttpRequestResponse.cpp:131
bool SetMethod(ByteCursor method) noexcept
Definition HttpRequestResponse.cpp:115
bool SetResponseCode(int response) noexcept
Definition HttpRequestResponse.cpp:154
HttpResponse(Allocator *allocator=ApiAllocator())
Definition HttpRequestResponse.cpp:136
Optional< int > GetResponseCode() const noexcept
Definition HttpRequestResponse.cpp:143
Definition MqttConnection.h:158
Definition Optional.h:19
#define AWS_CRT_CPP_API
Definition Exports.h:36
Definition Credentials.h:28
aws_http_header HttpHeader
Definition HttpConnection.h:35
Definition Credentials.h:23
Definition HttpRequestResponse.h:24
Definition HttpRequestResponse.h:19
Definition Allocator.h:13
aws_byte_cursor ByteCursor
Definition Types.h:31
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition Allocator.cpp:24
aws_allocator Allocator
Definition Allocator.h:14
Definition Allocator.h:11
Definition StringView.h:862