How do you send a HEAD HTTP request in Python 2?

前端 未结 11 2093
甜味超标
甜味超标 2020-11-22 11:40

What I\'m trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if http://somedomain/foo/ will return a

11条回答
  •  春和景丽
    2020-11-22 11:52

    As an aside, when using the httplib (at least on 2.5.2), trying to read the response of a HEAD request will block (on readline) and subsequently fail. If you do not issue read on the response, you are unable to send another request on the connection, you will need to open a new one. Or accept a long delay between requests.

提交回复
热议问题