9#include <unordered_map>
12#include <userver/engine/io/sockaddr.hpp>
13#include <userver/http/header_map.hpp>
14#include <userver/logging/log_helper_fwd.hpp>
15#include <userver/server/http/form_data_arg.hpp>
16#include <userver/server/http/http_method.hpp>
17#include <userver/server/http/http_response.hpp>
18#include <userver/utils/impl/projecting_view.hpp>
19#include <userver/utils/str_icase.hpp>
21USERVER_NAMESPACE_BEGIN
28namespace server::handlers {
33namespace server::
http {
38class HttpRequest
final {
40 using HeadersMap = USERVER_NAMESPACE::http::
headers::HeaderMap;
42 using HeadersMapKeys =
decltype(utils::impl::MakeKeysView(HeadersMap()));
44 using CookiesMap = 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;
95 const std::string&
GetArg(std::string_view arg_name)
const;
114 bool HasArg(std::string_view arg_name)
const;
148 const std::string&
GetPathArg(std::string_view arg_name)
const;
167 const std::string&
GetHeader(std::string_view header_name)
const;
169 const std::string& GetHeader(
const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name)
const;
170 const HeadersMap& GetHeaders()
const;
176 bool HasHeader(
const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name)
const;
187 void RemoveHeader(
const USERVER_NAMESPACE::http::
headers::PredefinedHeader& header_name);
191 const std::string&
GetCookie(
const std::string& cookie_name)
const;
213 void SetRequestBody(std::string body);
214 void ParseArgsFromBody();
216 std::chrono::steady_clock::time_point GetStartTime()
const;
230 void SetUpgradeWebsocket(std::function<
void(std::unique_ptr<engine::io::RwBase>&&, engine::
io::Sockaddr&&)> cb
232 void DoUpgrade(std::unique_ptr<engine::io::RwBase>&&, engine::
io::Sockaddr&& peer_name)
const;
238 HttpRequestImpl& impl_;