我发现解释http.client for Python的文档似乎有点稀疏。我想在请求上使用它,因为请求对我们的项目不起作用
因此,知道我正在使用Python的http.client,我一次又一次地看到request
和putrequest
。这两种方法都是在HTTPConnection
下定义的here
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.
另外,这两个的源代码都在this file中定义
根据我的猜测和阅读,与putrequest
相比request
似乎是一个更高级的API。对吗
答案:request()是多个函数的抽象版本,putrequest()就是其中之一。
虽然这在文档中有定义,但是很容易跳过回答这个问题的那一行
这一点在
http.client
文档的这一行中指出:相关问题 更多 >
编程相关推荐