#include <userver/server/http/http_response.hpp>
HTTP Response data.
Definition at line 68 of file http_response.hpp.
Public Types | |
| using | HeadersMap = ::http::headers::HeaderMap |
| using | HeadersMapKeys = decltype(utils::impl::MakeKeysView(HeadersMap())) |
| using | CookiesMap = Cookie::CookiesMap |
| using | CookiesMapKeys = decltype(utils::impl::MakeKeysView(CookiesMap())) |
Public Member Functions | |
| HttpResponse (const HttpResponse &)=delete | |
| HttpResponse (HttpResponse &&)=delete | |
| void | SetData (std::string data) |
| void | SetSharedData (std::shared_ptr< const std::string > data) |
| Sets response body without copying, keeping data alive. Useful for serving cached static content. | |
| const std::string & | GetData () const |
| bool | SetHeader (std::string name, std::string value) |
| Add a new response header or rewrite an existing one. | |
| bool | SetHeader (std::string_view name, std::string value) |
| Add a new response header or rewrite an existing one. | |
| bool | SetHeader (const ::http::headers::PredefinedHeader &header, std::string value) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | SetContentType (const ::http::ContentType &type) |
| Add or rewrite the Content-Type header. | |
| void | SetContentEncoding (std::string encoding) |
| Add or rewrite the Content-Encoding header. | |
| bool | SetStatus (HttpStatus status) noexcept |
| Set the HTTP response status code. | |
| void | SetThrottleReason (std::string log_reason, std::string http_header_reason) |
| Set the throttle reason in tracing and try to set the response headers. The X-YaTaxi-Ratelimited-By header is controlled by the server's allow-set-response-ratelimited-by static option and is disabled by default. Set the option to true to enable the header. The option does not affect the X-YaTaxi-Ratelimit-Reason header. Header updates follow the restrictions of server::http::HttpResponse::SetHeader. After headers are committed, they remain unchanged, but the current span, if any, is still tagged with the throttle reason. | |
| bool | ClearUserHeaders () |
| Remove all headers from response, except system headers. | |
| void | SetCookie (Cookie cookie) |
| Sets a cookie if it was not set before. | |
| void | ClearCookies () |
| Remove all cookies from response. | |
| HttpStatus | GetStatus () const noexcept |
| HeadersMapKeys | GetSystemHeaderNames () const |
| HeadersMapKeys | GetUserHeaderNames () const |
| const std::string & | GetHeader (std::string_view header_name) const |
| const std::string & | GetHeader (const ::http::headers::PredefinedHeader &header_name) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | HasHeader (std::string_view header_name) const |
| bool | HasHeader (const ::http::headers::PredefinedHeader &header_name) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| CookiesMapKeys | GetCookieNames () const |
| const Cookie & | GetCookie (std::string_view cookie_name) const |
| void | SetStatusServiceUnavailable () |
| void | SetStatusOk () |
| void | SetStatusNotFound () |
| bool | WaitForHeadersEnd () |
| void | SetHeadersEnd () |
| bool | IsHeadersEnd () const noexcept |
| bool | IsBodyStreamed () const noexcept |
| bool | IsSent () const noexcept |
Protected Member Functions | |
| HttpResponse (const HttpRequest &request, request::ResponseDataAccounter &data_accounter) | |
| HttpResponse (const HttpRequest &request, request::ResponseDataAccounter &data_accounter, std::chrono::steady_clock::time_point now, utils::StrCaseHash hasher) | |
Related Symbols | |
(Note that these are not member symbols.) | |
| void | SetThrottleReason |
| using server::http::HttpResponse::CookiesMap = Cookie::CookiesMap |
Definition at line 77 of file http_response.hpp.
| using server::http::HttpResponse::CookiesMapKeys = decltype(utils::impl::MakeKeysView(CookiesMap())) |
Definition at line 79 of file http_response.hpp.
| using server::http::HttpResponse::HeadersMap = ::http::headers::HeaderMap |
Definition at line 73 of file http_response.hpp.
| using server::http::HttpResponse::HeadersMapKeys = decltype(utils::impl::MakeKeysView(HeadersMap())) |
Definition at line 75 of file http_response.hpp.
| bool server::http::HttpResponse::ClearUserHeaders | ( | ) |
Remove all headers from response, except system headers.
| const Cookie & server::http::HttpResponse::GetCookie | ( | std::string_view | cookie_name | ) | const |
| CookiesMapKeys server::http::HttpResponse::GetCookieNames | ( | ) | const |
| const std::string & server::http::HttpResponse::GetHeader | ( | std::string_view | header_name | ) | const |
|
inlinenoexcept |
Definition at line 135 of file http_response.hpp.
| HeadersMapKeys server::http::HttpResponse::GetSystemHeaderNames | ( | ) | const |
| HeadersMapKeys server::http::HttpResponse::GetUserHeaderNames | ( | ) | const |
| bool server::http::HttpResponse::HasHeader | ( | std::string_view | header_name | ) | const |
|
inlinenodiscardnoexcept |
Definition at line 172 of file http_response.hpp.
|
inlinenodiscardnoexcept |
Definition at line 170 of file http_response.hpp.
|
inlinenodiscardnoexcept |
Definition at line 174 of file http_response.hpp.
| bool server::http::HttpResponse::SetHeader | ( | std::string | name, |
| std::string | value ) |
Add a new response header or rewrite an existing one.
| bool server::http::HttpResponse::SetHeader | ( | std::string_view | name, |
| std::string | value ) |
Add a new response header or rewrite an existing one.
|
noexcept |
Set the HTTP response status code.
|
inline |
Definition at line 164 of file http_response.hpp.
|
inline |
Definition at line 163 of file http_response.hpp.
|
inline |
Definition at line 162 of file http_response.hpp.
|
friend |
Definition at line 188 of file http_response.hpp.
|
friend |
Definition at line 187 of file http_response.hpp.
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.