考虑以下超链接:
<a href="http://www.cs.rutgers.edu/∼shklar/">
浏览器会提交什么 HTTP/1.0 请求?浏览器会提交什么 HTTP/1.1 请求?
如果将浏览器配置为联系 HTTP 代理,这些请求会改变吗?如果是,如何?
考虑以下超链接:
<a href="http://www.cs.rutgers.edu/∼shklar/">
浏览器会提交什么 HTTP/1.0 请求?浏览器会提交什么 HTTP/1.1 请求?
如果将浏览器配置为联系 HTTP 代理,这些请求会改变吗?如果是,如何?
虽然您可以tcpdump
用来转储实际的网络流量,curl
但从命令行测试 HTTP 对话肯定更方便。
HTTP/1.0 请求:
curl -v -0 http://www.cs.rutgers.edu/∼shklar/
* About to connect() to www.cs.rutgers.edu port 80 (#0)
* Trying 128.6.4.24...
* connected
* Connected to www.cs.rutgers.edu (128.6.4.24) port 80 (#0)
> GET /∼shklar/ HTTP/1.0
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: www.cs.rutgers.edu
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Wed, 31 Oct 2012 17:57:31 GMT
< Server: Apache/1.3.26 (Unix)
< Content-Type: text/html; charset=iso-8859-1
< Connection: close
HTTP/1.1 请求:
curl -v http://www.cs.rutgers.edu/∼shklar/
* About to connect() to www.cs.rutgers.edu port 80 (#0)
* Trying 128.6.4.24...
* connected
* Connected to www.cs.rutgers.edu (128.6.4.24) port 80 (#0)
> GET /∼shklar/ HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: www.cs.rutgers.edu
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Wed, 31 Oct 2012 17:59:47 GMT
< Server: Apache/1.3.26 (Unix)
< Content-Type: text/html; charset=iso-8859-1
< Transfer-Encoding: chunked
使用-x (or --proxy) <[protocol://][user@password]proxyhost[:port]>
开关使用代理并查看结果。
更多关于 curl 的信息:http: //curl.haxx.se/docs/manpage.html