2012-10-31 227 views
2

考虑以下超链接:HTTP GET请求结构

<a href="http://www.cs.rutgers.edu/∼shklar/"> 

什么HTTP/1.0请求将得到由浏览器提交的? 浏览器会提交什么HTTP/1.1请求?

如果浏览器被配置为 联系HTTP代理,这些请求是否会改变?如果是,如何?

回答

4

虽然您可以使用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://][[email protected]]proxyhost[:port]>开关使用代理和查看结果。

更多关于卷曲在这里:http://curl.haxx.se/docs/manpage.html