8#include <unordered_map>
10#include <userver/concurrent/queue.hpp>
11#include <userver/engine/single_consumer_event.hpp>
12#include <userver/http/content_type.hpp>
13#include <userver/http/header_map.hpp>
14#include <userver/server/http/http_response_cookie.hpp>
15#include <userver/server/request/response_base.hpp>
16#include <userver/utils/impl/projecting_view.hpp>
17#include <userver/utils/str_icase.hpp>
21USERVER_NAMESPACE_BEGIN
23namespace server::http {
27void OutputHeader(USERVER_NAMESPACE::http::
headers::HeadersString& header,
28 std::string_view key, std::string_view val);
37 using HeadersMap = USERVER_NAMESPACE::http::
headers::HeaderMap;
39 using HeadersMapKeys =
decltype(utils::impl::MakeKeysView(HeadersMap()));
41 using CookiesMap = Cookie::CookiesMap;
43 using CookiesMapKeys =
decltype(utils::impl::MakeKeysView(CookiesMap()));
46 HttpResponse(
const HttpRequestImpl& request,
47 request::ResponseDataAccounter& data_accounter);
48 HttpResponse(
const HttpRequestImpl& request,
49 request::ResponseDataAccounter& data_accounter,
50 std::chrono::steady_clock::time_point now,
52 ~HttpResponse()
override;
55 std::chrono::steady_clock::time_point failure_time)
override;
61 bool SetHeader(std::string name, std::string value);
66 bool SetHeader(std::string_view name, std::string value);
70 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header,
103 const std::string&
GetHeader(std::string_view header_name)
const;
106 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name)
121 const Cookie&
GetCookie(std::string_view cookie_name)
const;
125 void SendResponse(engine::
io::
RwBase& socket)
override;
128 void SetStatusServiceUnavailable()
override {
134 bool WaitForHeadersEnd()
override;
135 void SetHeadersEnd()
override;
139 void SetStreamBody();
140 bool IsBodyStreamed()
const override;
142 Queue::Producer GetBodyProducer();
146 std::size_t SetBodyStreamed(
148 USERVER_NAMESPACE::http::
headers::HeadersString& header);
151 std::size_t SetBodyNotStreamed(
153 USERVER_NAMESPACE::http::
headers::HeadersString& header);
155 const HttpRequestImpl& request_;
160 engine::SingleConsumerEvent headers_end_{
161 engine::SingleConsumerEvent::NoAutoReset()};
162 std::optional<Queue::Consumer> body_stream_;
163 std::optional<Queue::Producer> body_stream_producer_;
166void SetThrottleReason(http::HttpResponse& http_response,
167 std::string log_reason, std::string http_header_reason);