Server-side handle for writing an HTTP/2 response to one request.
More...
#include <cpp/a11/net/http2.h>
Server-side handle for writing an HTTP/2 response to one request.
Handed to an Http2RequestHandler. Either stream the response incrementally (SendHeaders() then Write()/Finish()) or emit it in one call with SendResponse().
◆ Abort()
| absl::Status a11::net::Http2ResponseWriter::Abort |
( |
absl::Status |
status | ) |
|
Aborts the response with the given status.
◆ DeferResponse()
| void a11::net::Http2ResponseWriter::DeferResponse |
( |
| ) |
|
Says this response will be sent after the handler returns.
A handler that returns without responding gets a 204, which is right for one that had nothing to say and wrong for one that handed this writer to something else: answering 204 to a WebSocket upgrade ends the stream the new owner was about to accept. Deferring suppresses that fallback, leaving the response to the owner and the timeout to the client.
◆ Done()
| a11::Task a11::net::Http2ResponseWriter::Done |
( |
| ) |
const |
- Returns
- An awaitable that resolves when the response is done.
◆ Finish()
| absl::Status a11::net::Http2ResponseWriter::Finish |
( |
| ) |
|
Signals the end of the response body.
◆ finished()
| bool a11::net::Http2ResponseWriter::finished |
( |
| ) |
const |
- Returns
- Whether the response has been finished.
◆ FinishWithTrailers()
| absl::Status a11::net::Http2ResponseWriter::FinishWithTrailers |
( |
HttpHeaders |
trailers | ) |
|
Ends the response body with a trailer section.
- Parameters
-
| trailers | Fields to send after the body; an empty list makes this Finish(). Pseudo-headers are not permitted in a trailer section. |
◆ headers_sent()
| bool a11::net::Http2ResponseWriter::headers_sent |
( |
| ) |
const |
- Returns
- Whether the response headers have been sent.
◆ PushPromise()
| absl::StatusOr< std::shared_ptr< Http2ResponseWriter > > a11::net::Http2ResponseWriter::PushPromise |
( |
std::string |
method, |
|
|
std::string |
path, |
|
|
HttpHeaders |
headers = {} |
|
) |
| |
Promises a response the client did not ask for (server push).
Sends a PUSH_PROMISE naming the request method and path, and returns the writer for its response – driven exactly like this one. Must be called before this response is finished: HTTP/2 does not allow a promise on a stream that has already closed.
- Parameters
-
| method | Method of the promised request; must be safe and cacheable. |
| path | Absolute path, including any query. |
| headers | Header fields of the promised request. |
- Returns
- The pushed response's writer, or an error – FailedPrecondition when the client did not enable push, or when this response has already finished.
◆ response_deferred()
| bool a11::net::Http2ResponseWriter::response_deferred |
( |
| ) |
const |
◆ SendHeaders()
| absl::Status a11::net::Http2ResponseWriter::SendHeaders |
( |
int |
status, |
|
|
HttpHeaders |
headers = {} |
|
) |
| |
Sends the response status and headers.
◆ SendResponse()
| absl::Status a11::net::Http2ResponseWriter::SendResponse |
( |
int |
status, |
|
|
HttpHeaders |
headers = {}, |
|
|
std::string |
body = {} |
|
) |
| |
Sends a complete response (status, headers, and body) in one call.
◆ stream_id()
| std::int32_t a11::net::Http2ResponseWriter::stream_id |
( |
| ) |
const |
|
inline |
- Returns
- The HTTP/2 stream identifier.
◆ Write()
| absl::Status a11::net::Http2ResponseWriter::Write |
( |
std::string |
data | ) |
|
Writes a chunk of response body data.
◆ Http1Connection
| friend class Http1Connection |
|
friend |
◆ Http2Connection
The documentation for this class was generated from the following files: