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
28namespace server::http {
33class HttpRequest
final {
35 using HeadersMap = USERVER_NAMESPACE::http::
headers::HeaderMap;
37 using HeadersMapKeys =
decltype(utils::impl::MakeKeysView(HeadersMap()));
40 std::unordered_map<std::string, std::string, utils::StrCaseHash>;
42 using CookiesMapKeys =
decltype(utils::impl::MakeKeysView(CookiesMap()));
45 explicit HttpRequest(HttpRequestImpl& impl);
46 ~HttpRequest() =
default;
56 const std::string& GetMethodStr()
const;
74 std::chrono::duration<
double> GetRequestTime()
const;
75 std::chrono::duration<
double> GetResponseTime()
const;
83 const std::string&
GetArg(
const std::string& arg_name)
const;
94 bool HasArg(
const std::string& arg_name)
const;
124 const std::string&
GetPathArg(
const std::string& arg_name)
const;
142 const std::string&
GetHeader(std::string_view header_name)
const;
145 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name)
147 const HeadersMap& GetHeaders()
const;
166 const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name);
170 const std::string&
GetCookie(
const std::string& cookie_name)
const;
192 void SetRequestBody(std::string body);
193 void ParseArgsFromBody();
195 std::chrono::steady_clock::time_point GetStartTime()
const;
207 void SetUpgradeWebsocket(
208 std::function<
void(std::unique_ptr<engine::io::RwBase>&&,
209 engine::
io::Sockaddr&&)>
211 void DoUpgrade(std::unique_ptr<engine::io::RwBase>&&,
212 engine::
io::Sockaddr&& peer_name)
const;
216 HttpRequestImpl& impl_;