gpt4 book ai didi

python - 如何向 pycurl 发出 HEAD 请求

转载 作者:太空宇宙 更新时间:2023-11-04 03:21:47 28 4
gpt4 key购买 nike

我需要使用 pycurl 发送 HTTP HEAD 请求。

这段代码

curl = pycurl.Curl()
...
curl.setopt(curl.CUSTOMREQUEST, "HEAD")
curl.perform()

产生错误:

< HTTP/1.1 200 OK
* Server nginx/1.6.2 is not blacklisted
< Server: nginx/1.6.2
< Date: # No matters
< Content-Type: text/html; charset=utf-8
< Connection: keep-alive
< Cache-Control: no-cache,no-store,must-revalidate
< Pragma: no-cache
< Expires: # No matters
< Last-Modified: # No matters
< Content-Security-Policy: # No matters
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: # No matters
< X-Content-Type-Options: nosniff
< Content-Encoding: gzip
* no chunk, no close, no size. Assume close to signal end
<
* Operation timed out after 15001 milliseconds with 0 bytes received
* Closing connection 1

谁能帮帮我?

最佳答案

你想要 NOBODY选项。就像没有 body 一样。仅更改 CUSTOMREQUEST 不会使 libcurl 更改其行为方式,它会认为它执行 GET,但您将其更改为 HEAD,然后事情就会变糟。

关于python - 如何向 pycurl 发出 HEAD 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34454986/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com