8#include <unordered_map>
10#include <userver/clients/http/error.hpp>
11#include <userver/clients/http/local_stats.hpp>
12#include <userver/http/header_map.hpp>
13#include <userver/server/http/http_response_cookie.hpp>
14#include <userver/utils/str_icase.hpp>
16USERVER_NAMESPACE_BEGIN
18namespace clients::
http {
26 SwitchingProtocols = 101,
34 NonAuthoritativeInformation = 203,
39 AlreadyReported = 208,
44 MultipleChoices = 300,
45 MovedPermanently = 301,
51 TemporaryRedirect = 307,
52 PermanentRedirect = 308,
57 PaymentRequired = 402,
60 MethodNotAllowed = 405,
62 ProxyAuthenticationRequired = 407,
67 PreconditionFailed = 412,
68 PayloadTooLarge = 413,
70 UnsupportedMediaType = 415,
71 RangeNotSatisfiable = 416,
72 ExpectationFailed = 417,
76 MisdirectedRequest = 421,
77 UnprocessableEntity = 422,
79 FailedDependency = 424,
81 UpgradeRequired = 426,
82 PreconditionRequired = 428,
83 TooManyRequests = 429,
84 RequestHeaderFieldsTooLarge = 431,
85 NginxNoResponse = 444,
86 UnavailableForLegalReasons = 451,
87 NginxRequestHeaderTooLarge = 494,
88 NginxSSLCertificateError = 495,
89 NginxSSLCertificateRequired = 496,
90 NginxHTTPRequestSenttoHTTPSPort = 497,
91 NginxClientClosedRequest = 499,
94 InternalServerError = 500,
97 ServiceUnavailable = 503,
99 HttpVersionNotSupported = 505,
100 VariantAlsoNegotiates = 506,
101 InsufficientStorage = 507,
103 BandwidthLimitExceeded = 509,
105 NetworkAuthenticationRequired = 511,
106 WebServerIsDown = 520,
107 ConnectionTimedOut = 522,
108 OriginIsUnreachable = 523,
109 TimeoutOccurred = 524,
110 SslHandshakeFailed = 525,
111 InvalidSslCertificate = 526,
114std::ostream& operator<<(std::ostream& os,
Status s);
117using Headers = USERVER_NAMESPACE::http::
headers::HeaderMap;
120class Response
final {
122 using CookiesMap = server::http::Cookie::CookiesMap;
124 Response() =
default;
130 std::string
body()
const& {
return response_; }
131 std::string&& body() && {
return std::move(response_); }
137 const Headers&
headers()
const {
return headers_; }
138 Headers& headers() {
return headers_; }
139 const CookiesMap& cookies()
const {
return cookies_; }
140 CookiesMap& cookies() {
return cookies_; }
147 static void RaiseForStatus(
int code,
const LocalStats& stats);
149 void raise_for_status()
const;
155 void SetStats(
const LocalStats& stats) { stats_ = stats; }
156 void SetStatusCode(
Status status_code) { status_code_ = status_code; }
161 std::string response_;