-
Notifications
You must be signed in to change notification settings - Fork 341
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
Is is possible to read the response before the whole request body is sent? #315
Comments
The server doesn't provide any kind of response until it's received the entire request, which includes headers and body. Fetch resolves once response headers (but not the body) have been fully received. Once you have a 413, the request should have finished sending. |
Thanks for the quick response! Actually, the server should be able to responsd whenever, shouldn't it? For example there's an nginx setting client_max_body_size that makes it respond with a 413 error after reaching the limit, but before the full request body was transferred. Correct me if I'm wrong, but the problem lied with the browsers, which would not allow reading the response before the whole body was sent. If fetch resolves after the response headers are sent, then I should be able to cancel the request on the client side. That's cool! |
HTTP servers aren't required to read the entire request before responding. See discussion on #229 for fetch() details. |
"I guess the more accurate question is: is promise returned by fetch(...) fulfilled with a response before the request body stream is done?" Yes, this can be the case. I think @jakearchibald was not aware of the conversation pointed out by @mnot. Closing this since there doesn't seem to be a problem here with the standard. Why wasn't this possible with |
There's a scenario in which a big file is being sent to the server from the client, and after reaching a request body size limit the server responds with a 413 error. In this case I'd like to cancel the request on the client.
It wasn't possible to handle such scenario with
XMLHttpRequest
. Is the fetch API able to do it?I guess the more accurate question is: is promise returned by
fetch(...)
fulfilled with a response before the request body stream is done?Sorry if the question has an obvious answer, I couldn't make it out from reading the spec.
The text was updated successfully, but these errors were encountered: