aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
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
31 {
32 public:
33 virtual ~HttpMessage();
34
35 HttpMessage(const HttpMessage &) = delete;
37 HttpMessage &operator=(const 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
98 struct aws_http_message *m_message;
99 std::shared_ptr<Aws::Crt::Io::InputStream> m_bodyStream;
100 };
101
106 {
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
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
#define AWS_CRT_CPP_API
Definition: Exports.h:37
Definition: HttpRequestResponse.h:31
std::shared_ptr< Aws::Crt::Io::InputStream > m_bodyStream
Definition: HttpRequestResponse.h:99
HttpMessage(HttpMessage &&)=delete
HttpMessage & operator=(HttpMessage &&)=delete
HttpMessage & operator=(const HttpMessage &)=delete
struct aws_http_message * m_message
Definition: HttpRequestResponse.h:98
Allocator * m_allocator
Definition: HttpRequestResponse.h:97
HttpMessage(const HttpMessage &)=delete
Definition: HttpRequestResponse.h:106
Definition: HttpRequestResponse.h:140
Definition: MqttClient.h:131
Definition: Optional.h:17
aws_http_header HttpHeader
Definition: HttpConnection.h:34
std::basic_istream< char, std::char_traits< char > > IStream
Definition: Types.h:37
aws_byte_cursor ByteCursor
Definition: Types.h:33
aws_allocator Allocator
Definition: StlAllocator.h:17
AWS_CRT_CPP_API Allocator * g_allocator
Definition: Api.cpp:23
Definition: Api.h:14
int index
Definition: cJSON.h:188
Definition: StringView.h:851