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 {
17 public:
18 ResponseBodyStream(ResponseBodyStream&&) = default;
19
20 // Send a chunk of response data. It may NOT generate
21 // exactly one HTTP chunk per call to PushBodyChunk().
22 void PushBodyChunk(std::string&& chunk, engine::Deadline deadline);
23
24 void SetHeader(const std::string&, const std::string&);
25
26 void SetHeader(std::string_view, const std::string&);
27
28 void SetEndOfHeaders();
29
30 void SetStatusCode(int status_code);
31
32 void SetStatusCode(HttpStatus status);
33
34 private:
35 friend class server::handlers::HttpHandlerBase;
36
37 ResponseBodyStream(
38 server::http::HttpResponse::Queue::Producer&& queue_producer,
39 server::http::HttpResponse& http_response);
40
41 bool headers_ended_{false};
42 HttpResponse::Queue::Producer queue_producer_;
43 server::http::HttpResponse& http_response_;
44};
45
46} // namespace server::http
47
48USERVER_NAMESPACE_END