0

The documentation I've found explaining http.client for Python seems a bit sparse. I want to use it over requests because requests has not worked for our project.

So, knowing that I'm using Python's http.client, I'm seeing again and again request and putrequest. Both methods are defined here under HTTPConnection.

HTTPConnection.request: This will send a request to the server using the HTTP request method method and the selector url.

HTTPConnection.putrequest: This should be the first call after the connection to the server has been made. It sends a line to the server consisting of the method string, the url string, and the HTTP version (HTTP/1.1). To disable automatic sending of Host: or Accept-Encoding: headers (for example to accept additional content encodings), specify skip_host or skip_accept_encoding with non-False values.

Also, the source code for both is defined in this file.

From my guess and reading things, it seems like request is a more high level API compared to putrequest. Is that correct?

yodama
  • 659
  • 1
  • 9
  • 21
  • 1
    Above "putrequest" in the docs there is "As an alternative to using the request() method described above, you can also send your request step by step, by using the four functions below.". – Michael Butscher Nov 08 '19 at 00:37
  • I am a fool. Thanks for pointing that out. – yodama Nov 08 '19 at 00:42

1 Answers1

0

The Answer: request() is an abstracted version of multiple functions, putrequest() being one of them.

Although this is defined in the documentation, it's easy to skip over the line that answers this question.

This is pointed out in this line of the http.client documentation:

As an alternative to using the request() method described above, you can also send your request step by step, by using the four functions below.

yodama
  • 659
  • 1
  • 9
  • 21