9#include <unordered_map>
12#include <userver/http/header_map.hpp>
13#include <userver/logging/log_helper_fwd.hpp>
14#include <userver/server/http/form_data_arg.hpp>
15#include <userver/server/http/http_method.hpp>
16#include <userver/server/http/http_response.hpp>
17#include <userver/utils/impl/projecting_view.hpp>
18#include <userver/utils/str_icase.hpp>
20USERVER_NAMESPACE_BEGIN
27namespace server::handlers {
32namespace server::http {
37class HttpRequest
final {
39 using HeadersMap = USERVER_NAMESPACE::http::
headers::HeaderMap;
41 using HeadersMapKeys =
decltype(utils::impl::MakeKeysView(HeadersMap()));
44 std::unordered_map<std::string, std::string, utils::StrCaseHash>;
46 using CookiesMapKeys =
decltype(utils::impl::MakeKeysView(CookiesMap()));
49 explicit HttpRequest(HttpRequestImpl& impl);
50 ~HttpRequest() =
default;
60 const std::string& GetMethodStr()
const;
78 std::chrono::duration<
double> GetRequestTime()
const;
79 std::chrono::duration<
double> GetResponseTime()
const;
89 const std::string&
GetArg(std::string_view arg_name)
const;
102 bool HasArg(std::string_view arg_name)
const;
136 const std::string&
GetPathArg(std::string_view arg_name)
const;
154 const std::string&
GetHeader(std::string_view header_name)
const;
157 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name)
159 const HeadersMap& GetHeaders()
const;
178 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name);
182 const std::string&
GetCookie(
const std::string& cookie_name)
const;
204 void SetRequestBody(std::string body);
205 void ParseArgsFromBody();
207 std::chrono::steady_clock::time_point GetStartTime()
const;
219 void SetUpgradeWebsocket(
220 std::function<
void(std::unique_ptr<engine::io::RwBase>&&,
221 engine::
io::Sockaddr&&)>
223 void DoUpgrade(std::unique_ptr<engine::io::RwBase>&&,
224 engine::
io::Sockaddr&& peer_name)
const;
230 HttpRequestImpl& impl_;