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

httpx.exceptions.ProtocolError: multiple Content-Length headers #740

Closed
freis opened this issue Jan 8, 2020 · 4 comments
Closed

httpx.exceptions.ProtocolError: multiple Content-Length headers #740

freis opened this issue Jan 8, 2020 · 4 comments

Comments

@freis
Copy link

freis commented Jan 8, 2020

This one I think its weird because I can't pinpoint what could cause this:

TRACE [2020-01-08 18:35:08] httpx.dispatch.connection_pool - acquire_connection origin=Origin(scheme='https' host='213.13.25.78' port=80)
TRACE [2020-01-08 18:35:08] httpx.dispatch.connection_pool - new_connection connection=HTTPConnection(origin=Origin(scheme='https' host='213.13.25.78' port=80))
TRACE [2020-01-08 18:35:08] httpx.config - load_ssl_context verify=False cert=None trust_env=True http2=True
TRACE [2020-01-08 18:35:08] httpx.dispatch.connection - start_connect tcp host='213.13.25.78' port=80 timeout=Timeout(timeout=10.0)
TRACE [2020-01-08 18:35:13] httpx.dispatch.connection_pool - acquire_connection origin=Origin(scheme='http' host='213.13.25.78' port=80)
TRACE [2020-01-08 18:35:13] httpx.dispatch.connection_pool - new_connection connection=HTTPConnection(origin=Origin(scheme='http' host='213.13.25.78' port=80))
TRACE [2020-01-08 18:35:13] httpx.dispatch.connection - start_connect tcp host='213.13.25.78' port=80 timeout=Timeout(timeout=10.0)
TRACE [2020-01-08 18:35:13] httpx.dispatch.connection - connected http_version='HTTP/1.1'
TRACE [2020-01-08 18:35:13] httpx.dispatch.http11 - send_headers method='GET' target='/' headers=Headers({'host': '213.13.25.78', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'})
TRACE [2020-01-08 18:35:13] httpx.dispatch.http11 - send_data data=Data(<0 bytes>)
TRACE [2020-01-08 18:35:13] httpx.dispatch.http11 - receive_event event=NEED_DATA
DEBUG [2020-01-08 18:35:13] httpx.dispatch.http11 - h11.RemoteProtocolError exception their_state=ERROR error_status_hint=400
@StephenBrown2
Copy link
Contributor

Can you give some example code that replicates this TRACE output?

@florimondmanca
Copy link
Member

florimondmanca commented Jan 8, 2020

It would also help to know as much as possible about your setup:

  • Python version
  • HTTPX version
  • OS
  • What kind of host are you trying to request.
  • Any special setup, such as custom certificates, proxies, etc.
  • Any snippet of code that can help reproduce the issue.

I think this applies to all potential bug reports.

In themselves these trace outputs are of very limited use, and I hope you understand we can’t be unlimitedly available to help you with debugging these. 😕

At this point, I may suggest you start digging into the HTTPX source code and potentially add more debug output to help you out.

@freis
Copy link
Author

freis commented Jan 8, 2020

@florimondmanca I understand it ^^ Just wanted to open these in case that someone already bumped into this issue. As for the details sorry for not being more specific at start. I will also try to look into this of course.

  • Python: 3.6.8
  • httpx==0.10.1
  • Linux ubuntu-bionic 4.15.0-72-generic
  • About the code is just a simples AsyncClient using Trio
  • About the host don't have much information, this was the curl I got:
* Rebuilt URL to: http://213.13.25.78:80/
*   Trying 213.13.25.78...
* TCP_NODELAY set
* Connected to 213.13.25.78 (213.13.25.78) port 80 (#0)
> GET / HTTP/1.1
> Host: 213.13.25.78
> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Server: nginx/1.0.4
< Content-Type: text/html
< Cache-Control: no-cache
< Content-Length: 570
< Accept-Ranges: bytes
< Date: Wed, 08 Jan 2020 18:58:14 GMT
< X-Varnish: 675616753
< Age: 0
< Via: 1.1 varnish
< Connection: keep-alive
< Content-Length: 570
<
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.0.4</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
* Connection #0 to host 213.13.25.78 left intact

@tomchristie
Copy link
Member

The server is responding with multiple Content-Length headers, which is a protocol violation.

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

4 participants