A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::net::Http2Options Struct Reference

Body-size limits, buffering thresholds, deadline, TLS, and HTTP protocol negotiation for an HTTP client or server. More...

#include <cpp/a11/net/http2.h>

Public Types

enum class  ProtocolPreference { kAuto , kHttp2 , kHttp11 }
 Client-side HTTP protocol preference / downgrade policy. More...
 

Public Member Functions

absl::Status Validate () const
 Validate size relationships, deadline, TLS, and protocol settings.
 

Public Attributes

size_t max_request_body_size = 32 * 1024 * 1024
 Request hard limit.
 
size_t max_response_body_size = 32 * 1024 * 1024
 Response hard limit.
 
size_t max_buffered_request_bytes
 Request backpressure bound.
 
size_t max_buffered_response_bytes
 Response backpressure bound.
 
absl::Time deadline = absl::InfiniteFuture()
 Connection-wide deadline.
 
Http2TlsOptions tls
 TLS and certificate policy.
 
bool enable_h2 = true
 Serve/accept HTTP/2 over TLS (ALPN "h2").
 
bool enable_h2c = true
 Serve/accept cleartext prior-knowledge HTTP/2.
 
bool enable_http1 = true
 Serve/accept HTTP/1.1 (ALPN and/or cleartext).
 
bool enable_push = false
 Client: accept HTTP/2 server pushes (SETTINGS_ENABLE_PUSH).
 
ProtocolPreference client_preference = ProtocolPreference::kAuto
 Client protocol preference; also governs cleartext attempt order.
 
bool client_allow_downgrade = true
 Whether a cleartext client may reconnect with the other protocol when its first attempt fails (ALPN makes TLS negotiation unambiguous already).
 
std::function< bool(std::string_view method, std::string_view path, const HttpHeaders &headers)> stream_request_body
 Server: decides from a request's head whether its body arrives incrementally.
 

Detailed Description

Body-size limits, buffering thresholds, deadline, TLS, and HTTP protocol negotiation for an HTTP client or server.

Member Enumeration Documentation

◆ ProtocolPreference

Client-side HTTP protocol preference / downgrade policy.

Enumerator
kAuto 

Prefer HTTP/2, fall back to HTTP/1.1 (ALPN order / downgrade).

kHttp2 

Require HTTP/2 (h2 over TLS, prior-knowledge h2c cleartext).

kHttp11 

Require HTTP/1.1.

Member Function Documentation

◆ Validate()

absl::Status a11::net::Http2Options::Validate ( ) const

Validate size relationships, deadline, TLS, and protocol settings.

Member Data Documentation

◆ client_allow_downgrade

bool a11::net::Http2Options::client_allow_downgrade = true

Whether a cleartext client may reconnect with the other protocol when its first attempt fails (ALPN makes TLS negotiation unambiguous already).

◆ client_preference

ProtocolPreference a11::net::Http2Options::client_preference = ProtocolPreference::kAuto

Client protocol preference; also governs cleartext attempt order.

◆ deadline

absl::Time a11::net::Http2Options::deadline = absl::InfiniteFuture()

Connection-wide deadline.

◆ enable_h2

bool a11::net::Http2Options::enable_h2 = true

Serve/accept HTTP/2 over TLS (ALPN "h2").

◆ enable_h2c

bool a11::net::Http2Options::enable_h2c = true

Serve/accept cleartext prior-knowledge HTTP/2.

◆ enable_http1

bool a11::net::Http2Options::enable_http1 = true

Serve/accept HTTP/1.1 (ALPN and/or cleartext).

◆ enable_push

bool a11::net::Http2Options::enable_push = false

Client: accept HTTP/2 server pushes (SETTINGS_ENABLE_PUSH).

Off by default, and advertised as off, so a peer cannot spend this side's streams and flow-control window on responses nobody asked for. A client that sets it must read Http2ResponseStream::NextPush() and either consume or Cancel() each pushed response, or those streams stay open.

◆ max_buffered_request_bytes

size_t a11::net::Http2Options::max_buffered_request_bytes
Initial value:
=
4 * 1024 * 1024

Request backpressure bound.

◆ max_buffered_response_bytes

size_t a11::net::Http2Options::max_buffered_response_bytes
Initial value:
=
4 * 1024 * 1024

Response backpressure bound.

◆ max_request_body_size

size_t a11::net::Http2Options::max_request_body_size = 32 * 1024 * 1024

Request hard limit.

◆ max_response_body_size

size_t a11::net::Http2Options::max_response_body_size = 32 * 1024 * 1024

Response hard limit.

◆ stream_request_body

std::function<bool(std::string_view method, std::string_view path, const HttpHeaders& headers)> a11::net::Http2Options::stream_request_body

Server: decides from a request's head whether its body arrives incrementally.

A request this accepts is dispatched to the handler as soon as its headers land, with HttpRequest::body_stream carrying the body as it arrives and HttpRequest::body left empty; every other request is buffered whole and dispatched once complete, which is what an unset predicate means. Reach for it when a request body is an open-ended stream of application messages rather than a document – the HTTP SSE transport's streaming outbound direction is exactly that. An extended CONNECT stream is delivered this way regardless.

Called on the connection's libuv thread, so keep it a cheap inspection of the head. max_buffered_request_bytes bounds what the stream holds while the handler is not reading, and max_request_body_size does not apply – a stream has no total length to compare against.

◆ tls

Http2TlsOptions a11::net::Http2Options::tls

TLS and certificate policy.


The documentation for this struct was generated from the following files: