#include <userver/clients/http/response.hpp>
Class that will be returned for successful request.
Definition at line 26 of file response.hpp.
Public Types | |
| enum class | RaiseIncludeBody : std::uint8_t { kNo = 0 , kYes = 1 } |
| Configuration whether to include the response body in the exception in raise_for_status. More... | |
| using | CookiesMap = server::http::Cookie::CookiesMap |
Public Member Functions | |
| std::string & | sink_string () |
| response string | |
| std::string | body () const & |
| body as string | |
| std::string && | body () && |
| std::string_view | body_view () const |
| body as string_view | |
| const Headers & | headers () const |
| return reference to headers | |
| Headers & | headers () |
| const CookiesMap & | cookies () const |
| CookiesMap & | cookies () |
| Status | status_code () const |
| status_code | |
| bool | IsOk () const |
| check status code | |
| bool | IsError () const |
| Whether the HTTP status is >=400 and was not explicitly marked expected by the request. This classification does not affect raise_for_status(). | |
| void | raise_for_status (RaiseIncludeBody include_body=RaiseIncludeBody::kNo) const |
Raise an exception depending on the response status. The body of the response may be included in the exception depending on the include_body. | |
| LocalStats | GetStats () const |
| returns statistics on request execution like count of opened sockets, connect time... | |
| void | SetStats (const LocalStats &stats) |
| void | SetStatusCode (Status status_code) |
| void | SetExpectedStatusCodes (ExpectedStatusCodes status_codes) |
| Replaces the expected HTTP codes used by clients::http::Response::IsError. An empty set restores the default classification of HTTP statuses >=400 as errors. The request applies its configured set before completion middleware runs. Changing a received response affects subsequent response classification only. It does not update the already recorded span or retry-budget accounting, change the HTTP status, or affect clients::http::Response::raise_for_status. To configure request tracing and retry-budget accounting, use clients::http::Request::SetExpectedStatusCodes before sending the request. | |
Static Public Member Functions | |
| static void | RaiseForStatus (int code, const LocalStats &stats) |
| static void | RaiseForStatus (int code, const LocalStats &stats, std::string_view message) |
| using clients::http::Response::CookiesMap = server::http::Cookie::CookiesMap |
Definition at line 28 of file response.hpp.
|
strong |
Configuration whether to include the response body in the exception in raise_for_status.
Definition at line 62 of file response.hpp.
|
inline |
Definition at line 37 of file response.hpp.
|
inline |
body as string
Definition at line 36 of file response.hpp.
|
inline |
body as string_view
Definition at line 40 of file response.hpp.
|
inline |
Definition at line 46 of file response.hpp.
|
inline |
Definition at line 45 of file response.hpp.
|
inline |
Definition at line 44 of file response.hpp.
|
inline |
return reference to headers
Definition at line 43 of file response.hpp.
|
inline |
Whether the HTTP status is >=400 and was not explicitly marked expected by the request. This classification does not affect raise_for_status().
Definition at line 54 of file response.hpp.
|
inline |
check status code
Definition at line 51 of file response.hpp.
| void clients::http::Response::raise_for_status | ( | RaiseIncludeBody | include_body = RaiseIncludeBody::kNo | ) | const |
Raise an exception depending on the response status. The body of the response may be included in the exception depending on the include_body.
| HttpClientException | for statuses [400; 500) |
| HttpServerException | for statuses [500; 600) |
|
inline |
Replaces the expected HTTP codes used by clients::http::Response::IsError. An empty set restores the default classification of HTTP statuses >=400 as errors. The request applies its configured set before completion middleware runs. Changing a received response affects subsequent response classification only. It does not update the already recorded span or retry-budget accounting, change the HTTP status, or affect clients::http::Response::raise_for_status. To configure request tracing and retry-budget accounting, use clients::http::Request::SetExpectedStatusCodes before sending the request.
Definition at line 85 of file response.hpp.
|
inline |
Definition at line 74 of file response.hpp.
|
inline |
Definition at line 75 of file response.hpp.
|
inline |
response string
Definition at line 33 of file response.hpp.