userver: userver/server/http/http_request_builder.hpp Source File
Loading...
Searching...
No Matches
http_request_builder.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/server/http/http_request_builder.hpp
4/// @brief @copybrief server::http::HttpRequestBuilder
5
6#include <memory>
7
8#include <userver/server/http/http_request.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace server::http {
13
14/// @brief HTTP Request Builder
15class HttpRequestBuilder final {
16public:
17 /// @cond
18 explicit HttpRequestBuilder(request::ResponseDataAccounter& data_accounter);
19 /// @endcond
20
21 HttpRequestBuilder();
22
23 explicit HttpRequestBuilder(const HttpRequest& data_accounter);
24
25 HttpRequestBuilder& SetRemoteAddress(engine::io::Sockaddr remote_address);
26
27 HttpRequestBuilder& SetMethod(HttpMethod method);
28
29 HttpRequestBuilder& SetHttpMajor(int http_major);
30
31 HttpRequestBuilder& SetHttpMinor(int http_minor);
32
33 HttpRequestBuilder& SetBody(std::string&& body);
34
35 HttpRequestBuilder& AddHeader(std::string&& header, std::string&& value);
36
37 HttpRequestBuilder& AddRequestArg(std::string&& key, std::string&& value);
38
39 HttpRequestBuilder& SetPathArgs(std::vector<std::pair<std::string, std::string>> args);
40
41 HttpRequestBuilder& SetUrl(std::string&& url);
42
43 HttpRequestBuilder& SetRequestPath(std::string&& path);
44
45 std::shared_ptr<HttpRequest> Build();
46
47 /// @cond
48 HttpRequestBuilder& SetIsFinal(bool is_final);
49
50 HttpRequestBuilder& SetFormDataArgs(
51 utils::impl::TransparentMap<std::string, std::vector<FormDataArg>, utils::StrCaseHash>&& form_data_args
52 );
53
54 HttpRequestBuilder& SetHttpHandler(const handlers::HttpHandlerBase& handler);
55
56 HttpRequestBuilder& SetTaskProcessor(engine::TaskProcessor& task_processor);
57
58 HttpRequestBuilder& SetHttpHandlerStatistics(handlers::HttpRequestStatistics& stats);
59
60 // TODO: remove?
61 HttpRequestBuilder& SetStreamProducer(impl::Http2StreamEventProducer&& producer);
62
63 // TODO: remove?
64 HttpRequestBuilder& SetResponseStreamId(std::int32_t stream_id);
65
66 HttpRequestBuilder& SetResponseStatus(HttpStatus status);
67
68 const HttpRequest& GetRef() const;
69
70 HttpResponse& GetHttpResponse();
71 /// @endcond
72
73private:
74 void ParseCookies();
75
76 std::shared_ptr<HttpRequest> request_;
77};
78
79} // namespace server::http
80
81USERVER_NAMESPACE_END