Hydra 0.0.1
A convenience networking library for modern C++
 
Loading...
Searching...
No Matches
http_response.h
1#ifndef SOURCEMETA_HYDRA_HTTP_RESPONSE_H
2#define SOURCEMETA_HYDRA_HTTP_RESPONSE_H
3
4#ifndef SOURCEMETA_HYDRA_HTTP_EXPORT
5#include <sourcemeta/hydra/http_export.h>
6#endif
7
8#include <sourcemeta/hydra/http_status.h>
9
10#include <optional> // std::optional
11#include <sstream> // std::ostringstream, std::istringstream
12#include <string> // std::string
13#include <unordered_map> // std::unordered_map
14#include <vector> // std::vector
15
16namespace sourcemeta::hydra::http {
17
20class SOURCEMETA_HYDRA_HTTP_EXPORT ClientResponse {
21public:
22 // We don't want to document this internal constructor
23#if !defined(DOXYGEN)
24 ClientResponse(const Status status,
25 std::unordered_map<std::string, std::string> &&headers,
26 std::ostringstream &&stream);
27#endif
28
40 auto status() const noexcept -> Status;
41
62 auto header(const std::string &key) const -> std::optional<std::string>;
63
81 auto headers() const -> const std::unordered_map<std::string, std::string> &;
82
99 auto empty() noexcept -> bool;
100
124 auto body() -> std::istringstream &;
125
126private:
127 Status status_;
128// Exporting symbols that depends on the standard C++ library is considered
129// safe.
130// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
131#if defined(_MSC_VER)
132#pragma warning(disable : 4251)
133#endif
134 std::unordered_map<std::string, std::string> headers_;
135 std::istringstream stream_;
136#if defined(_MSC_VER)
137#pragma warning(default : 4251)
138#endif
139};
140
141} // namespace sourcemeta::hydra::http
142
143#endif
Definition http_response.h:20
auto status() const noexcept -> Status
Status
Definition http_status.h:10