-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow strings or byte sequences as bodies? #1073
Comments
Apart from |
I guess it wouldn't be too bad to have HTML do this, if you really don't think other specs will have request bodies. (No specs want to ping a server?) "Extract" isn't a great fit as we don't want the MIME type, but maybe we can factor out some common primitive... |
Hmm, maybe the Reporting API? cc @clelland |
Yep, Reporting creates POST requests with bodies -- it sets the MIME type, and provides a byte sequence to Fetch. The byte sequence used is always the output of https://infra.spec.whatwg.org/#serialize-json-to-bytes, so it could probably use a string just as well, if the Fetch primitive were to be refactored. |
This simplifies things for several callers. Fixes #1073.
This simplifies things for several callers. This also cleans up several ReadableStream object operations in the process. Fixes #1073.
This is several issues in one...
HTML always invokes Fetch with byte sequence request bodies. The two invocations are:
I think we should allow this, instead of requiring HTML or other callers to create new
ReadableStream
instances. Fetch could, very early in the Fetch algorithm, construct a fixed ReadableStream instance.HTML also has a few places where it wants to supply a string as a response body in a synthetic response:
These are interesting because I know that Blink, at least, has a direct path for javascript: URLs and iframe srcdoc to set the resulting document's value as a string. Bytes never get involved, and the charset defined for the document is ignored. (I don't know if the HTML spec defines the charset of the produced documents very well for those cases...)
I'm not sure what we should do here. Maybe HTML's navigate algorithm should grow a new type of "resource", the string resource, since this seems very specific to that case? Or HTML could UTF-8 encode and created a fixed stream itself. Maybe with a helper defined in Fetch, like "created a fixed string body"?
I can't think of an easy way for Fetch to handle this in general, because we probably want to confine string-bodies to these navigation special cases; certainly any cases that might pass through service workers need to be stream-bodies.
Finally, HTML also treats script response bodies as byte sequences:
But this is already covered in #661, so we can ignore it for this issue.
The text was updated successfully, but these errors were encountered: