Skip to content
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

Server-side support for chunked requests #24139

Open
gterzian opened this issue Jun 14, 2020 · 6 comments
Open

Server-side support for chunked requests #24139

gterzian opened this issue Jun 14, 2020 · 6 comments

Comments

@gterzian
Copy link
Contributor

fetch/api/basic/request-upload.any.js introduces streaming request bodies(using a ReadableStream), and it's not clear to me if the server supports these types of requests.

Also note that the "Transfer-Encoding: chunked" header will be set for such requests, as per Step 4.2 of https://fetch.spec.whatwg.org/#concept-http-network-fetch.

I was trying this out in Servo, which in theory should pass the test, however I was getting an empty body back in the echo, and noticed the following output:

 0:04.54 INFO STDERR: 127.0.0.1 - - [13/Jun/2020 18:22:08] code 400, message Bad request syntax ('4')
 0:04.54 INFO STDERR: 127.0.0.1 - - [13/Jun/2020 18:22:08] "4" 400 -

I am not 100% certain that this is a server-side issue, as it might also still be a problem in Servo's client-side code.

@annevk
Copy link
Member

annevk commented Jun 14, 2020

cc @yutakahirano @yoichio

@annevk annevk added the fetch label Jun 14, 2020
@yoichio
Copy link
Contributor

yoichio commented Jun 15, 2020

Yes. I'm seeing exact same response, or empty body with fetch upload streaming feature on Chromium.
I don't know WPT server implementation. What component is supposed to update?

@gterzian
Copy link
Contributor Author

What component is supposed to update?

I believe the code is in /tools/wptserve

@gterzian
Copy link
Contributor Author

Ok so looking at https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Encoded_data

I'm pretty sure the 4 is the first line, indicating a four bytes chunk, in our case the "Test" body sent via the ReadableStream.

So I think on my side, the library I was using to do this is using chunked encoding by default when using their "stream" API(which I plugged into the ReadableStream), and the server doesn't know how to handle it.

Since wptserver is based on the Python(2?) stdlib server, I don't think it would support this out of the box. Python 3 also doesn't seem to come with a server supporting this out of the box(although it does come with a client that supports it).

@stephenmcgruer
Copy link
Contributor

At this point in time, we do not support chunked encoding. I believe doing so would be a non-trivial amount of work, though we would likely welcome outside contributions towards such a goal (note that a change of that magnitude would likely have to go through the RFC process first, essentially an initial design step).

If someone were to look towards implementing this support, it's important to consider what features tests would need out of the server, which can differ from what clients of a 'normal' server need. For example, we aim to enable tests to have the server do non-spec-compliant things, specifically so that tests can verify what browsers do in those error cases. So it could potentially be even trickier than implementing compliant chunked request support! :)

@annevk
Copy link
Member

annevk commented Jun 24, 2020

Note that we only need to do this if we decide that we want H/1 support for request body streams, which isn't a settled discussion. And if we support request body streams, the browser would be responsible for the framing, which means the server can be as strict as can be I think as it only needs to consume conforming data and explicitly reject/fail on non-conforming data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@stephenmcgruer @annevk @gterzian @yoichio @LukeZielinski and others