userver: userver/server/http/http_response_body_stream.hpp Source File
Loading...
Searching...
No Matches
http_response_body_stream.hpp
1#pragma once
2
3#include <string>
4
5#include <userver/server/http/http_response.hpp>
6#include <userver/server/request/response_base.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace server::handlers {
11class HttpHandlerBase;
12}
13
14namespace server::http {
15
16class ResponseBodyStream final {
17public:
18 ResponseBodyStream(ResponseBodyStream&&) = default;
19 ~ResponseBodyStream();
20
21 // Send a chunk of response data. It may NOT generate
22 // exactly one HTTP chunk per call to PushBodyChunk().
23 void PushBodyChunk(std::string&& chunk, engine::Deadline deadline);
24
25 void SetHeader(const std::string&, const std::string&);
26
27 void SetHeader(std::string_view, const std::string&);
28
29 void SetEndOfHeaders();
30
31 void SetStatusCode(int status_code);
32
33 void SetStatusCode(HttpStatus status);
34
35private:
36 friend class server::handlers::HttpHandlerBase;
37
38 ResponseBodyStream(HttpResponse::Producer&& queue_producer, HttpResponse& http_response);
39
40 bool headers_ended_{false};
41 HttpResponse::Producer queue_producer_;
42 HttpResponse& http_response_;
43};
44
45} // namespace server::http
46
47USERVER_NAMESPACE_END