1
A
回答
4
-I/--head
选项执行HEAD
请求。使用libcurl C API,您需要设置CURLOPT_NOBODY选项。
h = Curl::Easy.new("http://www.google.com")
h.set :nobody, true
h.perform
puts h.header_str
# HTTP/1.1 302 Found
# Location: http://www.google.fr/
# Cache-Control: private
# Content-Type: text/html; charset=UTF-8
# ...
作为替代方案,您可以像使用便利的捷径之一:
h = Curl::Easy.new("http://www.google.com")
# This sets the option behind the scenes, and call `perform`
h.http_head
puts h.header_str
# ...
或者这样一个
随着路边,你可以根据以下步骤在您的手柄设置此选项,使用类方法:
h = Curl::Easy.http_head("http://www.google.com")
puts h.header_str
# ...
注意:最终的快捷方式是Curl.head("http://www.google.com")
。这是说等到下一个路边释放使用它之前,因为它是不是工作在写这篇文章,并刚刚被修补:请参阅此pull request。
相关问题
- 1. HTTP请求头
- 2. HTTP头请求
- 3. 请求HTTP标头
- 4. Chrome扩展chrome.webRequest API - 一些HTTP请求头中的请求头
- 5. 解析HTTP请求授权头与Python
- 6. 如何仅请求与C#HTTP头?
- 7. http请求的HTTP请求
- 8. 解析http请求标头
- 9. 更改http请求标头
- 10. 监控HTTP请求头
- 11. 阿卡-HTTP的请求头
- 12. HTTP请求头字段“optdata”
- 13. 自定义HTTP请求头
- 14. 为HTTP创建头请求
- 15. “请求者”的HTTP头
- 16. express js - 一个http请求如何与其他请求不同?
- 17. HTTP请求与Node.js
- 18. HTTP请求与angularJS
- 19. http请求与powershell
- 20. HTTP请求URL是否不是HTTP请求标头的一部分?
- 21. 多个http请求在一个请求到不同的域
- 22. 异步HTTP请求与新线程上的HTTP请求
- 23. http头请求减慢脚本(python请求)
- 24. 与Erlang的HTTP POST请求
- 25. C++ Http请求与POCO
- 26. 正常HTTP请求与TCP连接+ HTTP标头
- 27. Chaning与Koa.js的两个HTTP请求
- 28. AngularJS窗体与多个http请求
- 29. http请求消息的边界
- 30. 转换一个请求HTTP POST龙卷风post请求