python: HTTP PUT with unencoded binary data

后端 未结 4 2541
难免孤独
难免孤独 2021-02-20 07:09

I cannot for the life of me figure out how to perform an HTTP PUT request with verbatim binary data in Python 2.7 with the standard Python libraries.

I thought I could d

4条回答
  •  暖寄归人
    2021-02-20 07:19

    Have you considered/tried using httplib?

    HTTPConnection.request(method, url[, body[, headers]])

    This will send a request to the server using the HTTP request method method and the selector url. If the body argument is present, it should be a string of data to send after the headers are finished. Alternatively, it may be an open file object, in which case the contents of the file is sent; this file object should support fileno() and read() methods. The header Content-Length is automatically set to the correct value. The headers argument should be a mapping of extra HTTP headers to send with the request.

提交回复
热议问题