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
48 bool SetBody(const std::shared_ptr<Aws::Crt::Io::IStream> &body) noexcept;
49
50 bool SetBody(const std::shared_ptr<Aws::Crt::Io::InputStream> &body) noexcept;
51
52 size_t GetHeaderCount() const noexcept;
53 Optional<HttpHeader> GetHeader(size_t index) const noexcept;
54 bool AddHeader(const HttpHeader &header) noexcept;
55 bool EraseHeader(size_t index) noexcept;
56
57 operator bool() const noexcept { return m_message != nullptr; }
58
59 struct aws_http_message *GetUnderlyingMessage() const noexcept { return m_message; }
60
61 protected:
62 HttpMessage(Allocator *allocator, struct aws_http_message *message) noexcept;
63
65 struct aws_http_message *m_message;
66 std::shared_ptr<Aws::Crt::Io::InputStream> m_bodyStream;
67 };
68
73 {
75
76 public:
77 HttpRequest(Allocator *allocator = g_allocator);
78
82 Optional<ByteCursor> GetMethod() const noexcept;
83
87 bool SetMethod(ByteCursor method) noexcept;
88
92 Optional<ByteCursor> GetPath() const noexcept;
93
97 bool SetPath(ByteCursor path) noexcept;
98
99 protected:
100 HttpRequest(Allocator *allocator, struct aws_http_message *message);
101 };
102
107 {
108 public:
109 HttpResponse(Allocator *allocator = g_allocator);
110
114 Optional<int> GetResponseCode() const noexcept;
115
119 bool SetResponseCode(int response) noexcept;
120 };
121 } // namespace Http
122 } // namespace Crt
123} // 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:66
HttpMessage(HttpMessage &&)=delete
struct aws_http_message * GetUnderlyingMessage() const noexcept
Definition: HttpRequestResponse.h:59
HttpMessage & operator=(HttpMessage &&)=delete
HttpMessage & operator=(const HttpMessage &)=delete
struct aws_http_message * m_message
Definition: HttpRequestResponse.h:65
Allocator * m_allocator
Definition: HttpRequestResponse.h:64
HttpMessage(const HttpMessage &)=delete
Definition: HttpRequestResponse.h:73
Definition: HttpRequestResponse.h:107
Definition: MqttClient.h:127
Definition: Optional.h:13
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:21
Definition: Api.h:17
int index
Definition: cJSON.h:188
Definition: StringView.h:846