Serve ASGI apps over HTTP
Author: jodalCreated Sep 27, 2026Updated Sep 27, 2026
LabelsA-ext-httpready-for-agent
:robot: Summary
An extension registers an ASGI app with the new http:asgi registry key (name, and factory: (config, core) -> ASGIApp). The HTTP frontend mounts it at /<name>/ on the same port as Tornado apps and static apps, through an HTTP bridge that Mopidy owns. The public type is a plain ASGI 3 callable, with no Starlette types (ADR 0001 in mopidy/workspace). Add Starlette as a dependency.
The bridge rules from the prototype are in the parent spec, under "HTTP bridge", "Routing" and "Scope". The most important rule: finish the Tornado response only from the handler method, never from send().
WebSockets and lifespan events are separate tickets.
Parent
mopidy/mopidy#2312
Acceptance criteria
- An
http:asgientry is mounted at/<name>/, and a request to/<name>redirects to/<name>/. - The scope has the full percent-decoded
path,raw_path,root_pathset to/<name>, andasgi.spec_versionset to2.4. Starlette routing andurl_forwork. - Request bodies arrive in parts, including chunked uploads.
- Streamed responses reach the client in parts, and
send()waits for the client (backpressure). - When the client disconnects, the app gets
http.disconnect, and Mopidy does not log an error when the app fails because the client is gone. - Responses have no Tornado default
Content-Type,ServerorDateheaders, and no ETag. - If an app's factory fails, the frontend logs the error and skips only that app.
- ASGI apps show on the web client list, and
default_appcan name an ASGI app. - Tornado apps, static apps and ASGI apps work on the same port at the same time.
- Starlette is a dependency of Mopidy. No ASGI server is added.
- Tests use small ASGI test apps through the test seam, with real HTTP clients.
Blocked by
- mopidy/mopidy#2313
Source: mopidy/mopidy