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

Uploading files shouldn't always use chunked, especally when HTTP1.0 is used. #126

Closed
Xinkai opened this issue Jul 22, 2014 · 3 comments · Fixed by #327
Closed

Uploading files shouldn't always use chunked, especally when HTTP1.0 is used. #126

Xinkai opened this issue Jul 22, 2014 · 3 comments · Fixed by #327
Labels

Comments

@Xinkai
Copy link

Xinkai commented Jul 22, 2014

aiohttp (0.9.0 when this bug is opened) always uses 'transfer-encoding': 'chunked' for file uploading, even if chunked is set to False or version is set to HttpVersion10.

This can be problematic in some cases. When the server doesn't support chunked multipart/form-data -- which is why I opened this issue -- the client doesn't respond for a very long time and then says aiohttp.errors.ClientConnectionError: Can not read status line.

IMO, the request method should respect the chunked switch, or even prefer the non-chunked way if the source is an actual file (content-length can be determined). I checked Firefox and the requests library, they don't send chunked packets by default.

@l04m33
Copy link
Contributor

l04m33 commented Aug 27, 2014

Setting Content-Length in the request headers should help.

aiohttp uses this field to determine the actual Transfer-Encoding:

  1. chunked set: Use chunked;
  2. chunked not set and Content-Length set: Use Content-Length;
  3. Neither chunked nor Content-Length is set: Depends on actual content type; File-like objects have no interface for determining real file size, so aiohttp uses chunked by default

It's all in the code: ClientRequest.update_transfer_encoding

@Xinkai
Copy link
Author

Xinkai commented Sep 7, 2014

Setting Content-Length won't work because before ClientRequest.update_transfer_encoding is called, ClientRequest.update_body_from_data(self, data) changed the value of chunked

    if data.is_form_data():
        self.chunked = self.chunked or 8196

Xinkai added a commit to Xinkai/aiohttp that referenced this issue Sep 8, 2014
This was referenced Sep 8, 2014
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants