Configuration¶
Every server option has CLI, environment, and TOML inputs:
- a CLI flag on the
h2corncommand - an
H2CORN_*environment variable - a key in a TOML config file (passed via
--configorH2CORN_CONFIG)
When the same option is provided in more than one place, the order of precedence is CLI > environment > TOML > defaults.
--host / --port and H2CORN_HOST / H2CORN_PORT are shortcuts for one TCP listener and cannot be combined with bind. --config and H2CORN_CONFIG select the TOML file; command-only controls are listed below.
Config(...) takes keyword-only options. Each entry lists the accepted Python input type, the normalized stored type, and any conversion the constructor applies. The direct constructor validates and normalizes its keyword arguments; it does not apply the CLI/environment/TOML precedence pipeline.
Option index¶
| Option | Default | CLI |
|---|---|---|
root_path | "" | -r, --root-path |
lifespan | 'auto' | --lifespan |
timeout_lifespan_startup | 60.0 | --timeout-lifespan-startup |
timeout_lifespan_shutdown | 30.0 | --timeout-lifespan-shutdown |
bind | ['127.0.0.1:8000'] | -b, --bind |
uds_permissions | None | --uds-permissions |
backlog | 1024 | --backlog |
reuse_port | False | --reuse-port / --no-reuse-port |
certfile | None | --certfile |
keyfile | None | --keyfile |
ca_certs | None | --ca-certs |
cert_reqs | 'none' | --cert-reqs |
pid | None | --pid |
user | None | -u, --user |
group | None | -g, --group |
umask | None | -m, --umask |
workers | 1 | -w, --workers |
runtime_threads | 2 | --runtime-threads |
loop | 'auto' | --loop |
loop_threads | 1 | --loop-threads |
max_requests | 0 | --max-requests |
max_requests_jitter | 0 | --max-requests-jitter |
timeout_worker_healthcheck | 30.0 | --timeout-worker-healthcheck |
http1 | True | --http1 / --no-http1 |
grpc | False | --grpc / --no-grpc |
access_log | True | --access-log / --no-access-log |
log_format | 'text' | --log-format |
max_concurrent_streams | 256 | --max-concurrent-streams |
limit_request_head_size | 1048576 | --limit-request-head-size |
limit_request_line | 16384 | --limit-request-line |
limit_request_fields | 100 | --limit-request-fields |
limit_request_field_size | 32768 | --limit-request-field-size |
h2_max_header_list_size | 1048576 | --h2-max-header-list-size |
h2_max_header_block_size | 1048576 | --h2-max-header-block-size |
h2_max_inbound_frame_size | 65536 | --h2-max-inbound-frame-size |
h2_initial_stream_window_size | 8388608 | --h2-initial-stream-window-size |
h2_initial_connection_window_size | 8388608 | --h2-initial-connection-window-size |
max_request_body_size | 1073741824 | --max-request-body-size |
request_policies | () | --request-policy |
limit_concurrency | 0 | --limit-concurrency |
limit_connections | 0 | --limit-connections |
timeout_handshake | 5.0 | --timeout-handshake |
timeout_graceful_shutdown | 30.0 | --timeout-graceful-shutdown |
timeout_keep_alive | 120.0 | --timeout-keep-alive |
timeout_request_header | 10.0 | --timeout-request-header |
timeout_request_body_idle | 60.0 | --timeout-request-body-idle |
h2_timeout_response_stall | 60.0 | --h2-timeout-response-stall |
h2_timeout_write | 60.0 | --h2-timeout-write |
websocket_max_message_size | 16777216 | --websocket-max-message-size |
websocket_per_message_deflate | True | --websocket-per-message-deflate / --no-websocket-per-message-deflate |
websocket_ping_interval | 60.0 | --websocket-ping-interval |
websocket_ping_timeout | 30.0 | --websocket-ping-timeout |
proxy_headers | False | --proxy-headers / --no-proxy-headers |
forwarded_allow_ips | ['127.0.0.1', '::1', 'unix'] | --forwarded-allow-ips |
forwarded_fields | ['for', 'proto'] | --forwarded-fields |
proxy_protocol | 'off' | --proxy-protocol |
server_header | 'off' | --server-header |
date_header | True | --date-header / --no-date-header |
response_headers | () | --header |
Application¶
Where the ASGI app lives and how it is loaded.
root_path¶
ASGI root path (to mount the application at a subpath).
| Default | "" |
| Python input | str |
| Python form | Keyword-only Config argument |
| Normalized value | str |
| CLI | -r, --root-path |
| Env | H2CORN_ROOT_PATH |
| TOML key | root_path |
| Precedence | CLI > environment > TOML > default |
lifespan¶
ASGI lifespan handling mode.
| Default | 'auto' |
| Python input | str |
| Python form | Keyword-only Config argument |
| Normalized value | Literal['auto', 'on', 'off'] |
| CLI | --lifespan |
| Env | H2CORN_LIFESPAN |
| TOML key | lifespan |
| Precedence | CLI > environment > TOML > default |
| Choices | auto, on, off |
timeout_lifespan_startup¶
Maximum time to wait for ASGI lifespan startup in seconds. Use 0 to disable.
| Default | 60.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-lifespan-startup |
| Env | H2CORN_TIMEOUT_LIFESPAN_STARTUP |
| TOML key | timeout_lifespan_startup |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
timeout_lifespan_shutdown¶
Maximum time to wait for ASGI lifespan shutdown in seconds. Use 0 to disable.
| Default | 30.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-lifespan-shutdown |
| Env | H2CORN_TIMEOUT_LIFESPAN_SHUTDOWN |
| TOML key | timeout_lifespan_shutdown |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
Listeners¶
How h2corn accepts connections.
bind¶
Listener addresses to bind. Repeat the flag to add more listeners. Supports HOST:PORT, [IPv6]:PORT, unix:PATH, and fd://N.
| Default | ['127.0.0.1:8000'] |
| Python input | str | tuple[object, ...] | list[object] | set[object] | frozenset[object] | None |
| Python form | Keyword-only Config argument |
| Normalized value | tuple[str, ...] |
| CLI | -b, --bind |
| Env | H2CORN_BIND |
| TOML key | bind |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Normalize bind strings or collections to validated listener strings. |
uds_permissions¶
Octal mask for Unix Domain Socket permissions.
| Default | None |
| Python input | int | None |
| Python form | Keyword-only Config argument |
| Normalized value | int | None |
| CLI | --uds-permissions |
| Env | H2CORN_UDS_PERMISSIONS |
| TOML key | uds_permissions |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept None or an exact built-in integer without coercion. |
backlog¶
Maximum number of queued connections on the listening socket.
| Default | 1024 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --backlog |
| Env | H2CORN_BACKLOG |
| TOML key | backlog |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
reuse_port¶
Set SO_REUSEPORT on the TCP listeners so other server processes can bind the same port — for zero-downtime deploys or independent processes. Workers of one server always share the inherited listener. TCP listeners only.
| Default | False |
| Python input | bool |
| Python form | Keyword-only Config argument |
| Normalized value | bool |
| CLI | --reuse-port / --no-reuse-port |
| Env | H2CORN_REUSE_PORT |
| TOML key | reuse_port |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact bool values without coercion. |
| Choices | true, false |
TLS¶
Direct TLS for TCP listeners. Leave unset when terminating TLS at a proxy.
certfile¶
PEM certificate chain file for direct TLS.
| Default | None |
| Python input | str | PathLike[str] | Path | None |
| Python form | Keyword-only Config argument |
| Normalized value | Path | None |
| CLI | --certfile |
| Env | H2CORN_CERTFILE |
| TOML key | certfile |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert string and PathLike inputs to Path while preserving None. |
keyfile¶
PEM private key file for direct TLS. Encrypted keys are not supported.
| Default | None |
| Python input | str | PathLike[str] | Path | None |
| Python form | Keyword-only Config argument |
| Normalized value | Path | None |
| CLI | --keyfile |
| Env | H2CORN_KEYFILE |
| TOML key | keyfile |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert string and PathLike inputs to Path while preserving None. |
ca_certs¶
PEM CA bundle used to verify client certificates for direct TLS.
| Default | None |
| Python input | str | PathLike[str] | Path | None |
| Python form | Keyword-only Config argument |
| Normalized value | Path | None |
| CLI | --ca-certs |
| Env | H2CORN_CA_CERTS |
| TOML key | ca_certs |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert string and PathLike inputs to Path while preserving None. |
cert_reqs¶
Client certificate verification mode for direct TLS.
| Default | 'none' |
| Python input | str |
| Python form | Keyword-only Config argument |
| Normalized value | Literal['none', 'optional', 'required'] |
| CLI | --cert-reqs |
| Env | H2CORN_CERT_REQS |
| TOML key | cert_reqs |
| Precedence | CLI > environment > TOML > default |
| Choices | none, optional, required |
Process and workers¶
Process identity, worker pool, and lifecycle on Unix.
pid¶
Write the server process PID to this file.
| Default | None |
| Python input | str | PathLike[str] | Path | None |
| Python form | Keyword-only Config argument |
| Normalized value | Path | None |
| CLI | --pid |
| Env | H2CORN_PID |
| TOML key | pid |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert string and PathLike inputs to Path while preserving None. |
user¶
User name or numeric UID for worker processes and created Unix sockets.
| Default | None |
| Python input | str | int | None |
| Python form | Keyword-only Config argument |
| Normalized value | str | int | None |
| CLI | -u, --user |
| Env | H2CORN_USER |
| TOML key | user |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept None, an exact int, or a non-empty str; decimal strings become ints. |
group¶
Group name or numeric GID for worker processes and created Unix sockets.
| Default | None |
| Python input | str | int | None |
| Python form | Keyword-only Config argument |
| Normalized value | str | int | None |
| CLI | -g, --group |
| Env | H2CORN_GROUP |
| TOML key | group |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept None, an exact int, or a non-empty str; decimal strings become ints. |
umask¶
Octal process umask to apply before creating files and sockets. Leave unset to preserve the inherited umask.
| Default | None |
| Python input | int | None |
| Python form | Keyword-only Config argument |
| Normalized value | int | None |
| CLI | -m, --umask |
| Env | H2CORN_UMASK |
| TOML key | umask |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept None or an exact built-in integer without coercion. |
workers¶
Number of worker processes to spawn.
| Default | 1 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | -w, --workers |
| Env | H2CORN_WORKERS |
| TOML key | workers |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
runtime_threads¶
Number of Tokio runtime worker threads per worker process.
| Default | 2 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --runtime-threads |
| Env | H2CORN_RUNTIME_THREADS |
| TOML key | runtime_threads |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
loop¶
Python event-loop implementation: 'auto' uses uvloop when installed (the 'h2corn[uvloop]' extra), otherwise the stdlib asyncio loop. h2corn runs its I/O in Rust, so this only affects how application callbacks are scheduled.
| Default | 'auto' |
| Python input | str |
| Python form | Keyword-only Config argument |
| Normalized value | Literal['auto', 'asyncio', 'uvloop'] |
| CLI | --loop |
| Env | H2CORN_LOOP |
| TOML key | loop |
| Precedence | CLI > environment > TOML > default |
| Choices | auto, asyncio, uvloop |
loop_threads¶
Number of Python event-loop threads per worker, balanced round-robin. Requires a free-threaded (no-GIL) interpreter; ignored on GIL builds.
Secondary loops require the built-in asyncio or uvloop factory (the default 'auto' resolves to one); multiple loop threads are rejected when embedded in a custom loop.
Each loop runs its own ASGI lifespan and state. Composes with workers — keep workers x loop_threads at or below the core count.
| Default | 1 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --loop-threads |
| Env | H2CORN_LOOP_THREADS |
| TOML key | loop_threads |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
max_requests¶
Maximum number of requests or WebSocket sessions a worker should complete before retiring. Use 0 to disable.
| Default | 0 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --max-requests |
| Env | H2CORN_MAX_REQUESTS |
| TOML key | max_requests |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
max_requests_jitter¶
Maximum jitter added to max_requests to stagger worker retirements. Use 0 to disable.
| Default | 0 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --max-requests-jitter |
| Env | H2CORN_MAX_REQUESTS_JITTER |
| TOML key | max_requests_jitter |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
timeout_worker_healthcheck¶
Maximum time between worker healthcheck heartbeats before the supervisor replaces the worker. Use 0 to disable.
| Default | 30.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-worker-healthcheck |
| Env | H2CORN_TIMEOUT_WORKER_HEALTHCHECK |
| TOML key | timeout_worker_healthcheck |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
HTTP and resource limits¶
Protocol behavior and per-connection bounds.
http1¶
Whether to accept HTTP/1.1 connections, including HTTP/1.1 WebSocket upgrade routes. Keep enabled when a production route uses HTTP/1.1. Disable only when every route uses HTTP/2; WebSocket routes then require an RFC 8441 extended CONNECT path supported by the client and proxy.
| Default | True |
| Python input | bool |
| Python form | Keyword-only Config argument |
| Normalized value | bool |
| CLI | --http1 / --no-http1 |
| Env | H2CORN_HTTP1 |
| TOML key | http1 |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact bool values without coercion. |
| Choices | true, false |
grpc¶
Whether to admit native gRPC requests identified by the case-insensitive application/grpc and application/grpc+<valid non-empty subtype> Content-Type media types. Parameters are ignored.
When disabled, native gRPC requests receive HTTP 415 before ASGI dispatch, even if a request policy matches. When enabled, unmatched native gRPC requests have no request-body size cap or idle timeout; a matching request policy can set explicit limits. HTTP/2 response-stall and write timeouts remain active. Connect and gRPC-Web media types remain ordinary HTTP.
This controls protocol admission, not network authentication; use a dedicated RPC listener and network policy when gRPC should be isolated.
| Default | False |
| Python input | bool |
| Python form | Keyword-only Config argument |
| Normalized value | bool |
| CLI | --grpc / --no-grpc |
| Env | H2CORN_GRPC |
| TOML key | grpc |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact bool values without coercion. |
| Choices | true, false |
access_log¶
Whether to log requests to stderr.
| Default | True |
| Python input | bool |
| Python form | Keyword-only Config argument |
| Normalized value | bool |
| CLI | --access-log / --no-access-log |
| Env | H2CORN_ACCESS_LOG |
| TOML key | access_log |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact bool values without coercion. |
| Choices | true, false |
log_format¶
Encoding for h2corn logs on stderr: the startup banner, worker lifecycle, errors and access records. 'json' emits one object per line so the stream can be shipped without parsing prose. Application logging and Python runtime exception hooks keep their own configuration.
| Default | 'text' |
| Python input | str |
| Python form | Keyword-only Config argument |
| Normalized value | Literal['text', 'json'] |
| CLI | --log-format |
| Env | H2CORN_LOG_FORMAT |
| TOML key | log_format |
| Precedence | CLI > environment > TOML > default |
| Choices | text, json |
max_concurrent_streams¶
Maximum active HTTP/2 streams per connection. At least 1.
| Default | 256 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --max-concurrent-streams |
| Env | H2CORN_MAX_CONCURRENT_STREAMS |
| TOML key | max_concurrent_streams |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
limit_request_head_size¶
Maximum total HTTP/1.1 request head size in bytes. Use 0 for no limit.
| Default | 1048576 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --limit-request-head-size |
| Env | H2CORN_LIMIT_REQUEST_HEAD_SIZE |
| TOML key | limit_request_head_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
limit_request_line¶
Maximum HTTP/1.1 request line size in bytes. Use 0 for no limit.
| Default | 16384 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --limit-request-line |
| Env | H2CORN_LIMIT_REQUEST_LINE |
| TOML key | limit_request_line |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
limit_request_fields¶
Maximum number of request header fields; HTTP/2 counts every decoded field, including duplicates. Use 0 for no limit.
| Default | 100 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --limit-request-fields |
| Env | H2CORN_LIMIT_REQUEST_FIELDS |
| TOML key | limit_request_fields |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
limit_request_field_size¶
Maximum individual HTTP/1.1 header field size in bytes. Use 0 for no limit.
| Default | 32768 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --limit-request-field-size |
| Env | H2CORN_LIMIT_REQUEST_FIELD_SIZE |
| TOML key | limit_request_field_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
h2_max_header_list_size¶
Maximum decoded HTTP/2 header list size in bytes. Use 0 for no limit.
| Default | 1048576 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --h2-max-header-list-size |
| Env | H2CORN_H2_MAX_HEADER_LIST_SIZE |
| TOML key | h2_max_header_list_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
h2_max_header_block_size¶
Maximum compressed HTTP/2 header block size in bytes while collecting HEADERS and CONTINUATION frames. Use 0 for no limit.
| Default | 1048576 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --h2-max-header-block-size |
| Env | H2CORN_H2_MAX_HEADER_BLOCK_SIZE |
| TOML key | h2_max_header_block_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
h2_max_inbound_frame_size¶
Maximum inbound HTTP/2 frame payload size to accept and advertise via SETTINGS_MAX_FRAME_SIZE.
| Default | 65536 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --h2-max-inbound-frame-size |
| Env | H2CORN_H2_MAX_INBOUND_FRAME_SIZE |
| TOML key | h2_max_inbound_frame_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
h2_initial_stream_window_size¶
HTTP/2 per-stream receive flow-control window in bytes (SETTINGS_INITIAL_WINDOW_SIZE). Controls inbound upload throughput; response throughput uses the peer-advertised send window. The default is 8 MiB.
| Default | 8388608 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --h2-initial-stream-window-size |
| Env | H2CORN_H2_INITIAL_STREAM_WINDOW_SIZE |
| TOML key | h2_initial_stream_window_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
h2_initial_connection_window_size¶
HTTP/2 connection-wide receive flow-control window in bytes. Bounds total charged upload bytes per connection; the default matches the 8 MiB stream window so one upload can use the whole connection budget.
| Default | 8388608 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --h2-initial-connection-window-size |
| Env | H2CORN_H2_INITIAL_CONNECTION_WINDOW_SIZE |
| TOML key | h2_initial_connection_window_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
max_request_body_size¶
Maximum request body size in bytes as an exact integer from 0 through 18_446_744_073_709_551_615. Use 0 for no limit. Native gRPC requests receive HTTP 415 when grpc=False and are exempt by default when grpc=True; Connect and gRPC-Web requests use this limit.
| Default | 1073741824 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --max-request-body-size |
| Env | H2CORN_MAX_REQUEST_BODY_SIZE |
| TOML key | max_request_body_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
request_policies¶
Ordered path-specific body and HTTP/2 response-stall policies. Each rule supplies all three values; the first exact path or terminal /* subtree match replaces the global values.
Protocol behavior. Native gRPC admission is controlled by grpc; when disabled, gRPC requests receive HTTP 415 even if a path rule matches. When enabled, unmatched native gRPC requests have no request-body size limit or idle timeout. Connect and gRPC-Web requests use the global values unless a path rule matches. The global HTTP/2 response-stall timeout still applies to RPC responses.
Path matching. Paths are raw ASCII URI paths without query or fragment text and match case-sensitively before the query, without percent-decoding or root_path changes. /* matches every normal HTTP path. Rules apply to HTTP/1 and HTTP/2; WebSockets keep their dedicated policy.
Input forms:
- Environment:
H2CORN_REQUEST_POLICIESaccepts a TOML array of inline tables. - CLI: repeat
--request-policywith one TOML inline table per rule. Explicit CLI rules replace the inherited table as a whole. - Python: pass a tuple of
RequestPolicyrecords.
Use 0 to disable an individual limit or timer. Config validation rejects timeout values outside the runtime monotonic-clock range.
| Default | () |
| Python input | tuple[RequestPolicy, ...] |
| Python form | Keyword-only Config argument |
| Normalized value | tuple[RequestPolicy, ...] |
| CLI | --request-policy |
| Env | H2CORN_REQUEST_POLICIES |
| TOML key | request_policies |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Require an immutable tuple of validated RequestPolicy records. |
limit_concurrency¶
Maximum number of concurrent ASGI request or session tasks per worker. Use 0 for no limit.
| Default | 0 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --limit-concurrency |
| Env | H2CORN_LIMIT_CONCURRENCY |
| TOML key | limit_concurrency |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
limit_connections¶
Maximum number of live client connections per worker. Use 0 for no limit.
| Default | 0 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --limit-connections |
| Env | H2CORN_LIMIT_CONNECTIONS |
| TOML key | limit_connections |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
Timeouts¶
Connection-level timeouts in seconds. For the optional timeouts, 0 disables the timer. For timeout_graceful_shutdown, 0 means no graceful wait — stop immediately rather than waiting for in-flight work.
timeout_handshake¶
Maximum time from accepting a connection to a finished PROXY preamble, TLS handshake and protocol preface, in seconds. Use 0 to disable.
| Default | 5.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-handshake |
| Env | H2CORN_TIMEOUT_HANDSHAKE |
| TOML key | timeout_handshake |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
timeout_graceful_shutdown¶
Maximum time for workers to finish in-flight requests on shutdown, in seconds.
| Default | 30.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-graceful-shutdown |
| Env | H2CORN_TIMEOUT_GRACEFUL_SHUTDOWN |
| TOML key | timeout_graceful_shutdown |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
timeout_keep_alive¶
Idle keep-alive timeout in seconds. Use 0 to disable.
| Default | 120.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-keep-alive |
| Env | H2CORN_TIMEOUT_KEEP_ALIVE |
| TOML key | timeout_keep_alive |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
timeout_request_header¶
Idle timeout in seconds while reading an HTTP request head or an HTTP/2 header block. Use 0 to disable.
| Default | 10.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-request-header |
| Env | H2CORN_TIMEOUT_REQUEST_HEADER |
| TOML key | timeout_request_header |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
timeout_request_body_idle¶
Idle timeout in seconds while reading an HTTP request body. Use 0 to disable. Native gRPC requests receive HTTP 415 when grpc=False and are exempt by default when grpc=True; Connect and gRPC-Web requests use this timeout.
| Default | 60.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --timeout-request-body-idle |
| Env | H2CORN_TIMEOUT_REQUEST_BODY_IDLE |
| TOML key | timeout_request_body_idle |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
h2_timeout_response_stall¶
Timeout in seconds for HTTP/2 response body bytes pinned behind peer flow control. Use 0 to disable.
| Default | 60.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --h2-timeout-response-stall |
| Env | H2CORN_H2_TIMEOUT_RESPONSE_STALL |
| TOML key | h2_timeout_response_stall |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
h2_timeout_write¶
Maximum time in seconds to finish pending HTTP/2 frame output and transport flushing. Progress does not renew the deadline; expiry closes the connection and every stream. Use 0 to disable.
| Default | 60.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --h2-timeout-write |
| Env | H2CORN_H2_TIMEOUT_WRITE |
| TOML key | h2_timeout_write |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
WebSocket¶
Limits and keep-alive for RFC 6455 and RFC 8441 WebSockets.
websocket_max_message_size¶
Maximum WebSocket message size in bytes. Defaults to 16 MiB; use 0 for no limit.
| Default | 16777216 |
| Python input | int |
| Python form | Keyword-only Config argument |
| Normalized value | int |
| CLI | --websocket-max-message-size |
| Env | H2CORN_WEBSOCKET_MAX_MESSAGE_SIZE |
| TOML key | websocket_max_message_size |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact built-in integers without coercion. |
websocket_per_message_deflate¶
Whether to negotiate permessage-deflate for WebSockets when the client offers it.
| Default | True |
| Python input | bool |
| Python form | Keyword-only Config argument |
| Normalized value | bool |
| CLI | --websocket-per-message-deflate / --no-websocket-per-message-deflate |
| Env | H2CORN_WEBSOCKET_PER_MESSAGE_DEFLATE |
| TOML key | websocket_per_message_deflate |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact bool values without coercion. |
| Choices | true, false |
websocket_ping_interval¶
Interval in seconds between server WebSocket ping frames. Use 0 to disable.
| Default | 60.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --websocket-ping-interval |
| Env | H2CORN_WEBSOCKET_PING_INTERVAL |
| TOML key | websocket_ping_interval |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
websocket_ping_timeout¶
Time limit in seconds to wait for a pong after a server WebSocket ping. Use 0 to disable. No effect while websocket_ping_interval is 0.
| Default | 30.0 |
| Python input | float |
| Python form | Keyword-only Config argument |
| Normalized value | float |
| CLI | --websocket-ping-timeout |
| Env | H2CORN_WEBSOCKET_PING_TIMEOUT |
| TOML key | websocket_ping_timeout |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Convert exact integers to float; reject bool, non-finite, and negative values. |
Proxy and response headers¶
Trust boundaries with the upstream proxy and default response headers.
proxy_headers¶
Enable forwarding-header processing for peers in forwarded_allow_ips; forwarded_fields selects the facts and dialect.
| Default | False |
| Python input | bool |
| Python form | Keyword-only Config argument |
| Normalized value | bool |
| CLI | --proxy-headers / --no-proxy-headers |
| Env | H2CORN_PROXY_HEADERS |
| TOML key | proxy_headers |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact bool values without coercion. |
| Choices | true, false |
forwarded_allow_ips¶
Allowed IPs or networks (in CIDR notation) for proxy headers. Use '*' to trust all.
| Default | ['127.0.0.1', '::1', 'unix'] |
| Python input | str | tuple[object, ...] | list[object] | set[object] | frozenset[object] | None |
| Python form | Keyword-only Config argument |
| Normalized value | tuple[str, ...] |
| CLI | --forwarded-allow-ips |
| Env | H2CORN_FORWARDED_ALLOW_IPS |
| TOML key | forwarded_allow_ips |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Normalize a string or collection, then validate each proxy peer. |
forwarded_fields¶
Forwarding facts to interpret from a trusted proxy: for, proto, host, port, prefix select X-Forwarded-* fields; forwarded selects RFC 7239 Forwarded. The dialects cannot be combined.
| Default | ['for', 'proto'] |
| Python input | str | tuple[object, ...] | list[object] | set[object] | frozenset[object] | None |
| Python form | Keyword-only Config argument |
| Normalized value | tuple[str, ...] |
| CLI | --forwarded-fields |
| Env | H2CORN_FORWARDED_FIELDS |
| TOML key | forwarded_fields |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Trim, lowercase, deduplicate, and validate forwarded-field names. |
proxy_protocol¶
Expect HAProxy's PROXY protocol on inbound connections.
| Default | 'off' |
| Python input | str |
| Python form | Keyword-only Config argument |
| Normalized value | Literal['off', 'v1', 'v2'] |
| CLI | --proxy-protocol |
| Env | H2CORN_PROXY_PROTOCOL |
| TOML key | proxy_protocol |
| Precedence | CLI > environment > TOML > default |
| Choices | off, v1, v2 |
server_header¶
Identify the server in a Server header: off sends none, on sends the name, full adds the version. Any other value goes through --header, which also wins over this.
| Default | 'off' |
| Python input | str |
| Python form | Keyword-only Config argument |
| Normalized value | Literal['off', 'on', 'full'] |
| CLI | --server-header |
| Env | H2CORN_SERVER_HEADER |
| TOML key | server_header |
| Precedence | CLI > environment > TOML > default |
| Choices | off, on, full |
date_header¶
Whether to add a default Date header when the application sets none.
| Default | True |
| Python input | bool |
| Python form | Keyword-only Config argument |
| Normalized value | bool |
| CLI | --date-header / --no-date-header |
| Env | H2CORN_DATE_HEADER |
| TOML key | date_header |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Accept exact bool values without coercion. |
| Choices | true, false |
response_headers¶
Default response headers in lowercase name: value form, added only when the application did not set that name itself. Repeat the flag to add more headers.
| Default | () |
| Python input | str | tuple[object, ...] | list[object] | set[object] | frozenset[object] | None |
| Python form | Keyword-only Config argument |
| Normalized value | tuple[str, ...] |
| CLI | --header |
| Env | H2CORN_RESPONSE_HEADERS |
| TOML key | response_headers |
| Precedence | CLI > environment > TOML > default |
| Python normalization | Headers from a value that may be one header or a collection of them. A lone string is one header, not a comma-separated list: commas belong to header values, so 'cache-control: public, max-age=60' is a single header and splitting it produced a second entry that was not one. |
Command-only CLI controls¶
These flags control application loading, development reload, or process actions rather than a Config value.
Command-only flags: -h, --help¶
Print command help, then exit.
Command-only flags: -c, --config¶
Select the TOML file; H2CORN_CONFIG selects the same file.
Command-only flags: --version¶
Print the installed h2corn version, then exit.
Command-only flags: --check-config¶
Validate configuration and TLS, then exit.
Command-only flags: --print-config¶
Print the fully resolved configuration, then exit.
Command-only flags: --factory¶
Construct an application on each running request loop using the zero-argument target.
Command-only flags: --app-dir¶
Import the target from this directory.
Command-only flags: --env-file¶
Load application environment before import.
Command-only flags: --reload¶
Watch application files and restart one development worker.
Command-only flags: --reload-dir¶
Add a development reload directory; repeatable.
Command-only flags: --reload-include¶
Add a development reload glob; repeatable.
Command-only flags: --reload-exclude¶
Add a development reload exclusion; repeatable.
Command-only flags: --host¶
TCP host convenience input for bind; H2CORN_HOST is equivalent when H2CORN_BIND is unset.
Command-only flags: -p, --port¶
TCP port convenience input for bind; H2CORN_PORT is equivalent when H2CORN_BIND is unset.
Building a Config programmatically¶
Config is a frozen dataclass; instantiate it directly or use Config.from_env(), Config.from_mapping(), or Config.from_toml(). Each option entry above gives its keyword-only Python input and normalized value types. See the Config API reference for helper signatures.