Skip to content

Move HTTP from cowboy to livery - #17

Open
benoitc wants to merge 1 commit into
mainfrom
feature/livery-http
Open

Move HTTP from cowboy to livery#17
benoitc wants to merge 1 commit into
mainfrom
feature/livery-http

Conversation

@benoitc

@benoitc benoitc commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Serves HTTP through livery 0.7.0 instead of cowboy, and drives the test suites with livery_client instead of hackney.

What changes

  • The listener is owned by a new supervised hornbeam_listener; hornbeam:info/0 and hornbeam:is_running/0 replace ranch introspection.
  • hornbeam_handler is a livery handler. WSGI and ASGI responses resolve through livery_resp:stream_deferred/1 in the per-request process, so request-body chunks and Python events share one mailbox.
  • WebSocket runs on the ws_handler behaviour (new hornbeam_ws_handler); hornbeam_websocket keeps the upgrade entry point, scope building, and the session registry.
  • Duplicate request headers are preserved in the ASGI scope and joined with ", " in WSGI HTTP_* keys.
  • New max_body option (default infinity) caps the request body at the listener.

Breaking

  • Route shape: routes are livery router entries {Method | '_', Pattern, HandlerFun | {Mod, Fun}} instead of cowboy {Path, HandlerModule, Opts} tuples. Cowboy handler modules are rejected with {error, {invalid_route, _}}.
  • Inactive config keys: max_request_line_size, max_header_size and max_headers are still accepted but do nothing (not exposed by livery).
  • hornbeam_wsgi removed: the classic build_environ/1,2 path was dead code; the live path is hornbeam_request:build_wsgi_tuple/2.

Requires livery 0.7.0

Five behaviours depend on the 0.7.0 release: livery_req:inform/3 for 103 Early Hints, the peer on plain HTTP/1.1 requests (WSGI REMOTE_ADDR, ASGI client), synchronous connection teardown in livery:stop_service/1, max_frame_size/compress on livery_ws:upgrade/3, and {remote, Code, Reason} in the ws handler's terminate/2.

Also fixes the /early-hints route in the ASGI test app, which sent status 103 through http.response.start (treated as the final head) rather than http.response.informational, so it had never worked.

Known limitations

  • TLS serves HTTP/1.1 only; cowboy's start_tls negotiated HTTP/2 via ALPN. Wiring livery's https (h2) listener is a follow-up.
  • 103 Early Hints go out on HTTP/1.1 and HTTP/2 but not HTTP/3, which has no interim responses in livery yet. The http.response.early_hints ASGI extension is advertised accordingly.

Serve HTTP through livery 0.7.0 instead of cowboy, and drive the test
suites with livery_client instead of hackney.

- The listener is owned by a new supervised hornbeam_listener;
  hornbeam:info/0 and hornbeam:is_running/0 replace ranch introspection.
- hornbeam_handler is a livery handler. WSGI and ASGI responses resolve
  through livery_resp:stream_deferred/1 in the per-request process, so
  request-body chunks and Python events share one mailbox.
- WebSocket runs on the ws_handler behaviour (new hornbeam_ws_handler);
  hornbeam_websocket keeps the upgrade entry point, scope building, and
  the session registry.
- Duplicate request headers are preserved in the ASGI scope and joined
  with ", " in WSGI HTTP_* keys.
- New max_body option (default infinity) caps the request body.

Breaking: routes are livery router entries
{Method | '_', Pattern, HandlerFun | {Mod, Fun}} rather than cowboy
{Path, HandlerModule, Opts} tuples; cowboy handler modules are rejected.
max_request_line_size, max_header_size and max_headers are accepted but
inactive. The dead hornbeam_wsgi build_environ path is removed.

TLS still serves HTTP/1.1 only; wiring livery's h2 listener is a
follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant