aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
Loading...
Searching...
No Matches
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 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
#define AWS_CRT_CPP_API
Definition Exports.h:36
Definition HttpRequestResponse.h:35
std::shared_ptr< Aws::Crt::Io::InputStream > m_bodyStream
Definition HttpRequestResponse.h:103
HttpMessage(HttpMessage &&)=delete
HttpMessage & operator=(HttpMessage &&)=delete
HttpMessage & operator=(const HttpMessage &)=delete
struct aws_http_message * m_message
Definition HttpRequestResponse.h:102
Allocator * m_allocator
Definition HttpRequestResponse.h:101
HttpMessage(const HttpMessage &)=delete
Definition HttpRequestResponse.h:110
Definition HttpRequestResponse.h:145
Definition MqttConnection.h:158
Definition Optional.h:19
aws_http_header HttpHeader
Definition HttpConnection.h:34
aws_byte_cursor ByteCursor
Definition Types.h:31
aws_allocator Allocator
Definition Allocator.h:14
AWS_CRT_CPP_API Allocator * ApiAllocator() noexcept
Definition Allocator.cpp:24
Definition Allocator.h:11
Definition StringView.h:862