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(std::string& header, std::string_view key,
28 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()
override;
51 std::chrono::steady_clock::time_point failure_time)
override;
57 bool SetHeader(std::string name, std::string value);
62 bool SetHeader(std::string_view name, std::string value);
66 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header,
99 const std::string&
GetHeader(std::string_view header_name)
const;
102 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name)
117 const Cookie&
GetCookie(std::string_view cookie_name)
const;
121 void SendResponse(engine::
io::
RwBase& socket)
override;
124 void SetStatusServiceUnavailable()
override {
130 bool WaitForHeadersEnd()
override;
131 void SetHeadersEnd()
override;
135 void SetStreamBody();
136 bool IsBodyStreamed()
const override;
138 Queue::Producer GetBodyProducer();
142 std::size_t SetBodyStreamed(engine::
io::
RwBase& socket, std::string& header);
145 std::size_t SetBodyNotStreamed(engine::
io::
RwBase& socket,
146 std::string& header);
148 const HttpRequestImpl& request_;
153 engine::SingleConsumerEvent headers_end_;
154 std::optional<Queue::Consumer> body_stream_;
155 std::optional<Queue::Producer> body_stream_producer_;
158void SetThrottleReason(http::HttpResponse& http_response,
159 std::string log_reason, std::string http_header_reason);