-
Notifications
You must be signed in to change notification settings - Fork 603
Feature Request — Runtime APIs: API for Early Hints #757
Description
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.