HTTP GET/CONNECT代理区别举例:
HTTP Proxy Server :
Access Web Site: www.example.com/index.php
1) 无代理:
GET /index.php HTTP/1.1
HOST: www.example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,**;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: xxxxxx
Cookie: xxxxxx
Cache-Control: max-age=0
2) HTTP GET 代理(HTTP1.0/HTTP1.1都支持) - socket首先与127.0.0.1:8080建立连接
GET http:/www.example.com/index.php HTTP/1.1
HOST: www.example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,**;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: xxxxxx
Cookie: xxxxxx
Cache-Control: max-age=0
3) HTTP CONNECT代理(只有HTTP1.1支持) - socket首先与127.0.0.1:8080建立连接
CONNECT http:/www.example.com/index.php HTTP/1.1
HOST: www.example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: xxxxxx
Cookie: xxxxxx
Cache-Control: max-age=0
注:HTTP CONNECT是在HTTP1.1协议上才新增的命令,用于支撑https加密。
所以,许多支持http connect的http proxy,比如squid,默认都限制只允许访问外部的443端口,其它端口不提供代理服务。