userver: userver/server/request/task_inherited_request.hpp Source File
Loading...
Searching...
No Matches
task_inherited_request.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/request/task_inherited_request.hpp
4/// @brief Functions that provide access to HttpRequest stored in
5/// TaskInheritedVariable.
6
7#include <string>
8#include <string_view>
9
10#include <boost/container/small_vector.hpp>
11#include <boost/range/iterator_range.hpp>
12
13#include <userver/http/header_map.hpp>
14
15USERVER_NAMESPACE_BEGIN
16
17namespace http::headers {
18class PredefinedHeader;
19} // namespace http::headers
20
21namespace server::http {
22class HttpRequestImpl;
23} // namespace server::http
24
25namespace server::request {
26
27struct Header {
28 std::string_view name;
29 std::string value;
30
31 Header(std::string_view name, std::string value) : name(name), value(std::move(value)) {}
32};
33
35
36/// @brief Get a header from server::http::HttpRequest that is handled by the
37/// current task hierarchy.
38/// @return Header value or an empty string, if none such
39const std::string& GetPropagatedHeader(std::string_view header_name);
40
41/// @overload
42const std::string& GetPropagatedHeader(const USERVER_NAMESPACE::http::headers::PredefinedHeader& header_name);
43
44/// @brief Checks whether specified header exists in server::http::HttpRequest
45/// that is handled by the current task hierarchy.
46/// @return `true` if the header exists, `false` otherwise
47bool HasPropagatedHeader(std::string_view header_name);
48
49/// @overload
50bool HasPropagatedHeader(const USERVER_NAMESPACE::http::headers::PredefinedHeader& header_name);
51
52/// @brief Get a headers that is handled by the current task hierarchy.
54
55/// @brief Set a headers that is handled by the current task hierarchy.
56void SetPropagatedHeaders(HeadersToPropagate headers);
57
58/// @brief Get a query parameter from server::http::HttpRequest that is handled
59/// by the current task hierarchy.
60/// @return Parameter value or an empty string, if none such
61const std::string& GetTaskInheritedQueryParameter(std::string_view name);
62
63/// @brief Checks whether specified query parameter exists in
64/// server::http::HttpRequest that is handled by the current task hierarchy.
65/// @return `true` if the parameter exists, `false` otherwise
66bool HasTaskInheritedQueryParameter(std::string_view name);
67
68} // namespace server::request
69
70USERVER_NAMESPACE_END