-
Notifications
You must be signed in to change notification settings - Fork 351
Feature detecting streaming requests #1470
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
Comments
Does |
Nah, that's true in Safari. The main problem here is that Safari supports requests with stream bodies, but it rejects when they're passed to fetch. Here was the old feature detect I used to work around the Safari issue: const supportsRequestStreamsP = (async () => {
const supportsStreamsInRequestObjects = !new Request('', {
body: new ReadableStream(),
method: 'POST',
}).headers.has('Content-Type');
if (!supportsStreamsInRequestObjects) return false;
return fetch('data:a/a;charset=utf-8,', {
method: 'POST',
body: new ReadableStream(),
}).then(() => true, () => false);
})();
// Note: supportsRequestStreamsP is a promise.
if (await supportsRequestStreamsP) {
// …
} else {
// …
} …but I'm hoping we won't have to do that now we have |
Interesting. How about asking for their plan at WebKit/standards-positions#24? |
Thanks! |
I'm going to close this as there is test coverage for this. But let me explicitly copy @youennf here so he knows to watch out for this when WebKit gets around to the feature. |
It would be nice to have a synchronous feature detect for streaming requests. This currently works with the Chrome implementation:
This tests that:
duplex
is implemented as part ofRequestInit
body
can be aReadableStream
. Otherwise, it's converted to a string and gets atext/plain
content type.However, it's possible that an implementation could support these two things, but reject when that request is passed to
fetch()
because it doesn't support request streams. In fact, Safari already behaves like this, but it doesn't implementduplex
so the test still works.Is it reasonable to expect the above feature detect to mean "fetch supports streaming requests"? Should this be enforced with spec text and/or a wpt?
The text was updated successfully, but these errors were encountered: