-
Notifications
You must be signed in to change notification settings - Fork 339
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
Developer-controlled streams for request/response #88
Comments
For H1, you'd just close the connection. For H2, you'd cancel the stream.
As noted elsewhere, that's not very interoperable with existing, deployed servers; while some will accept chunked encoding, most will 411 (Length Required) if there's no Content-Length, because they don't want to infinitely buffer the request. One way around this would be to specify that if Content-Length is set, you'll only write that many bytes to the wire, and error if it tries to write more. |
Basic test: web-platform-tests/wpt#4362. More tests are expected to be written as part of the implementation effort. Further work: #441. Fixes #88.
See whatwg/fetch#88 for context.
Basic tests: web-platform-tests/wpt#4362. Fetch Standard PR: #425. |
@annevk: Is |
@amn yeah, that's what we ended up with in step 4 and 5 of https://fetch.spec.whatwg.org/#concept-http-network-fetch. |
I have played around with and implemented bi-directional streaming for both HTTP/1 and HTTP/2 in While it's not possible to demonstrate in a web browser, here is a simple example of streaming from the server to the client: https://utopia-falcon-heroku.herokuapp.com/beer/index In addition, using the
In some cases you can optimise this logic to avoid closing the connection, but this is roughly what
I also implemented support for WebSockets, and it's such an orthogonal concept, especially in the design of the server, that I really believe and hope that we can build something better directly on top of HTTP/2. WebSockets seems like a step in the wrong direction. |
So, what is the status of bi-directional streaming in the browser? Does it work yet? |
No. |
Bi-di H1 is not standards compliant, not compatible with middleboxes, and doesn't align with how browsers "think about" HTTP. Bi-di H2 is technically possible. However, I think the principle from RFC6540 that "HTTP/2 provides an optimized transport for HTTP semantics." should be adhered to. |
@ricea it is standards compliant, what makes you say it's not? It's just that some middleboxes make it hard to deploy at scale. |
What part of the H1 spec disallows bi-directional streaming? |
@ioquatix RFC 7231 5.1.1
|
@ricea That seems to apply to the "Expect" header. Additionally, I don't see how that prevents bi-directional streaming. Can you elaborate? |
In other words, it's perfectly fine to send a response before you've received the entire request, but it can only depend on the parts of the request received up until that point. True bi-di would mean that later parts of the response depend on later parts of the request. Anyway, I don't want to get into standards-lawyering. Standards can be changed. Real-world compatibility is far more important. |
I'm not sure how you derive this interpretation from that one paragraph which appears to just talk about sending
I don't think anyone here is standards-lawyering, I am genuinely interested in the standard prevents bi-directional communication. I would expect something like "The server must wait until the entire request is received before sending the response" or something to that effect. I also agree that real-world compatibility is important. |
@yutakahirano I'm trying to understand why this test claims that various stream uploads should fail... They seem to succeed in browsers as far as I can tell. |
@bzbarsky which test are you referring to? https://github.com/web-platform-tests/wpt/pull/4362/files? |
Yes. All browsers currently fail the |
Thank you for fixing the tests. The failure is caused by https://fetch.spec.whatwg.org/#concept-request-transmit-body. It rejects any chunk other than Uint8Array. |
@yutakahirano OK, but either the test is not exercising this line or browsers are not implementing it. My suspicion is on the former, since browsers also fail the "Fetch with POST with ReadableStream" test, due to getting back |
@bzbarsky I don't think any browser supports upload streams at the moment. (There's some outstanding issues with that too, see the streams issue labels.) |
Ah, I see. I would have expected lack of support to lead to failed responses, not success responses with empty bodies, but maybe they're just buggy around that too... |
@bzbarsky from the name it looks like it's a thing designed to echo what was posted, which I would expect to always succeed. Usually that's preferable over encoding some of the test logic on the server part as then you'd need to look at that in order to debug the failures. |
Right, but my point is that I would expect browsers to fail the fetch rather than posting nothing when passed something they don't support? That is, my issue is with the sender-side behavior here, not the server. |
I see, that's an unfortunate side effect of |
I thought about that, but then I would expect the body to be |
It looks like a bug in the tests of sorts. If I add |
Oh, indeed! That's using an arrow function with a block on the RHS of the |
FWIW, patch at web-platform-tests/wpt#21718. |
…t, a=testonly Automatic update from web-platform-tests Fetch: improve ReadableStream upload test See whatwg/fetch#88 (comment) onward. -- wpt-commits: 867cf376fd8ec8e39a5025e2dccb307c1c2773bb wpt-pr: 21718
…t, a=testonly Automatic update from web-platform-tests Fetch: improve ReadableStream upload test See whatwg/fetch#88 (comment) onward. -- wpt-commits: 867cf376fd8ec8e39a5025e2dccb307c1c2773bb wpt-pr: 21718 UltraBlame original commit: d5e0c700360058cd2d46d713c5c457cc8a1feb47
…t, a=testonly Automatic update from web-platform-tests Fetch: improve ReadableStream upload test See whatwg/fetch#88 (comment) onward. -- wpt-commits: 867cf376fd8ec8e39a5025e2dccb307c1c2773bb wpt-pr: 21718 UltraBlame original commit: d5e0c700360058cd2d46d713c5c457cc8a1feb47
…t, a=testonly Automatic update from web-platform-tests Fetch: improve ReadableStream upload test See whatwg/fetch#88 (comment) onward. -- wpt-commits: 867cf376fd8ec8e39a5025e2dccb307c1c2773bb wpt-pr: 21718 UltraBlame original commit: d5e0c700360058cd2d46d713c5c457cc8a1feb47
…t, a=testonly Automatic update from web-platform-tests Fetch: improve ReadableStream upload test See whatwg/fetch#88 (comment) onward. -- wpt-commits: 867cf376fd8ec8e39a5025e2dccb307c1c2773bb wpt-pr: 21718
Are we certain the WPT server is setup to handle the streaming/chunked requests of I am currently getting a bunch of:
with the "Fetch with POST with ReadableStream" always failing due to the body apparently being empty. I see the failure is experienced by all browsers, where the behavior hasn't been implemented yet, and there was another problem with the test discussed above, however I am actually struggling to make the test pass in Servo, where in theory it should work. The problem might be client side, however after extensive debugging I'm looking for other places to blame :) |
No, nothing else creates that kind of request so there could well be issues. |
Ok, I've opened an issue in WPT to track this: web-platform-tests/wpt#24139 |
Falcon works and has been tested, if you want a server which can accept both posted chunked, content-length (half closed) and HTTP/2 whatever. I think I included a link to an example above somewhere. |
First https://github.com/yutakahirano/fetch-with-streams needs to be integrated. So developers can access the stream of request/response. Next is giving them control over the stream.
fetch(url, { body })
where body is a stream which gets random stuff (not bytes) enqueued in it?BufferSource
, and ... does what?<form>
MIME types)The text was updated successfully, but these errors were encountered: