3

I am receiving a the error requests.exceptions.ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read)) from a server using the Request package in Python.

It is my understanding from the post How to tell the HTTP server to not send chunked encoding that one way around this is to tell the server not to send chunked encoding, specifically by specifying HTTP/1.0 in the request.

How do i go about doing this using the Requests package?

1

1 Answer 1

4

You can try setting the HTTP version used in the httplib backend used by Requests.

On Python 2, you can do that like so:

import httplib httplib.HTTPConnection._http_vsn = 10 httplib.HTTPConnection._http_vsn_str = 'HTTP/1.0' 

and with Python 3, httplib was renamed http.client, so you'd do

import http.client http.client.HTTPConnection._http_vsn = 10 http.client.HTTPConnection._http_vsn_str = 'HTTP/1.0' 

Issue 2341 on Requests' GitHub shows that at least one person has done it this way—and also that it is definitely NOT SUPPORTED by Requests. In particular, the library will make no effort to ensure that only HTTP/1.0 compatible headers are sent, so stuff could very well break.

There is no supported way to set the HTTP protocol version with the Requests library.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.