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

Enable to remove "Content-Length: 0" for GET Request #2167

Closed
ga0 opened this issue Aug 4, 2017 · 13 comments
Closed

Enable to remove "Content-Length: 0" for GET Request #2167

ga0 opened this issue Aug 4, 2017 · 13 comments

Comments

@ga0
Copy link

ga0 commented Aug 4, 2017

Long story short

When I send GET request to some http server with the "Content-Length: 0" header, will cause a aiohttp.ServerDisconnectedError. If I remove this header, everything goes well.

I don't know why these server hate empty content-length header so much.

Expected behaviour

Some args to remove Content-Length if it is 0 and method is GET.

Steps to reproduce

You can test by using the comands below.

curl -v -H "Content-Length: 0" http://115.238.34.168

curl -v http://115.238.34.168 

Your environment

aiohttp: 2.0.7

OS & Python:

  • macOS with Python 3.6.1
  • CentOS7 with Python 3.4.5
@socketpair
Copy link
Contributor

https://stackoverflow.com/questions/978061/http-get-with-request-body?answertab=active#tab-top

Content length mean presensce of a body, but with zero length. I prefer to close as "not a bug". No one http-client will send such requests. And sending body with GET-request difinitely signify a bug in client. RFC on HTTP is not strict enough, so current implementation of this case still leaves aiohttp RFC-compliant. Handling such reqests will not bring any benefits, just code bloat.

Why you want such functionality ?

Also please update aiohttp and re-test.

@ga0
Copy link
Author

ga0 commented Aug 11, 2017

  • Why you want such functionality ?

Because I found send GET request with "Content-Length: 0" header to some kind of servers will cause a bad request error.

  • Also please update aiohttp and re-test.

I have tried aiohttp-2.2.5, still a "Content-Length: 0" in the request's header.

@socketpair
Copy link
Contributor

Since it's not an security error, does not fix any real problem, does not add new functionality, I'm -3 for this issue.

@fafhrd91
Copy link
Member

is it possible to disable content-length with skip_auto_headers?

@asvetlov
Copy link
Member

Unfortunately no.

@fafhrd91
Copy link
Member

I think we should support this use case

@asvetlov
Copy link
Member

Agree.
I see two options:

  1. Respect skip_auto_headers in Content-Length and Content-Encoding
  2. Implement Introduce session.make_request() API #2019 and add a low level control for all HTTP request transformation details.

I prefer second bullet but it requires much more work.
Skipping mandatory fields like Content-Length in our prime API could make a mess (not 100% sure but I have bad guts feeling about this approach).

@socketpair
Copy link
Contributor

Sorry, I did not catch original problem :(. As I think, Aiohttp has a bug. GET/HEAD/TRACE-requests hould not send content-length in any case.

@socketpair
Copy link
Contributor

socketpair commented Aug 12, 2017

Please review #2191

@ga0
Copy link
Author

ga0 commented Sep 6, 2017

I appreciate that you value this issue. 👍
I have to ask when this issue will be solved, or merged into the master branch? Do you have a plan?

I apologize for my poor English.
Thank you all you guys!

@asvetlov
Copy link
Member

Fixed by #2167

@herono2010
Copy link

"Connection:Keep-Alive" and "Content-Length:0" should be together.

@asvetlov
Copy link
Member

asvetlov commented Sep 6, 2019

Why?
Moreover, Connection: keep-alive is not required by HTTP/1.1 at all.

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

No branches or pull requests

5 participants