Skip to content

Feature Request — Runtime APIs: API for Early Hints #757

@marcusdarmstrong

Description

@marcusdarmstrong

Background:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103
https://blog.cloudflare.com/early-hints/

For my application (and presumably others with this as a design goal), we can trivially determine (some of) the asset URLs we're going to need on the document load, far ahead of knowing what the status code will be. Currently, Workerd lacks an explicit facility for declaring early hints from the application, with Cloudflare's public offering requiring that the eventual response header be committed to extract them.

My potentially naive proposal here would be to accept generators as fetch handlers, allowing yields of Response objects with a 103 status, but a context object based API would seem to be viable too. Pursing use of the Response object in either API would technically require either spec divergence or upstream agreement, as Response is spec'd to throw a RangeError for status codes < 200.

While I have very limited experience in the C++ world, it's very important to some of my employer's architectural goals/possibly a blocker to our ability to use workerd, so I'd be happy to try to work towards contributing this if we can establish agreement on desirability and API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions