2012-10-31 192 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