如何在控制台上的 Ruby 中使用 net/http 打印默认 HTTP GET/POST REQUEST/RESPONSE 标头并在请求中添加新标头
我想使用 net/http 在控制台上打印 GET/POST http 标头,如下所示。
GET /en HTTP/1.1
Host: www.html5rocks.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Access-Control-Allow-Origin: *
X-UA-Compatible: IE=Edge,chrome=1
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Sat, 18 Feb 2012 09:10:23 GMT
Server: Google Frontend
Content-Length: 8940
可以这样做吗?
I want to print GET/POST http headers like following on Console using net/http.
GET /en HTTP/1.1
Host: www.html5rocks.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Access-Control-Allow-Origin: *
X-UA-Compatible: IE=Edge,chrome=1
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Sat, 18 Feb 2012 09:10:23 GMT
Server: Google Frontend
Content-Length: 8940
Is it possible to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过以下方式打印标题:
You can print headers by this way: