使用 HTTP 代理时,浏览器会发生哪些变化?
Which changes do a browser make when using an HTTP Proxy?
想象一个向远程服务器发出 HTTP 请求的网络浏览器,例如 site.example.com
如果浏览器随后被配置为使用代理服务器,我们称其为使用端口 8080 的 proxy.example.com,现在的请求有哪些不同?
显然请求现在发送到 proxy.example.com:8080,但肯定还有其他更改才能使代理向原始 url?
发出请求
When making a request to a proxy, other than a CONNECT or server-wide
OPTIONS request (as detailed below), a client MUST send the target
URI in absolute-form as the request-target.
absolute-form = absolute-URI
The proxy is requested to either service that request from a valid
cache, if possible, or make the same request on the client's behalf
to either the next inbound proxy server or directly to the origin
server indicated by the request-target. Requirements on such
"forwarding" of messages are defined in Section 5.7.
An example absolute-form of request-line would be:
GET http://www.example.org/pub/WWW/TheProject.html HTTP/1.1
因此,在没有代理的情况下,连接到 www.example.org:80
:
GET /pub/WWW/TheProject.html HTTP/1.1
Host: www.example.org
使用代理服务器 proxy.example.com:8080
:
GET http://www.example.org/pub/WWW/TheProject.html HTTP/1.1
Host: www.example.org
在后一种情况下,Host
header 是可选的(对于 HTTP/1.0 客户端),无论如何都必须由代理重新计算。
代理只是代表原始客户端发出请求。因此名称 "proxy",与法律术语中的含义相同。浏览器将他们的请求发送给代理,代理向请求的服务器发出请求(或不请求,取决于代理是否要转发或拒绝此请求),服务器 returns 对代理的响应,代理 returns 对原始客户端的响应。服务器将看到的内容没有根本区别,除了原始客户端将显示为代理服务器这一事实。代理可能会也可能不会更改请求,它可能会也可能不会缓存它;这意味着如果代理决定交付缓存版本,服务器可能根本不会收到请求。
想象一个向远程服务器发出 HTTP 请求的网络浏览器,例如 site.example.com
如果浏览器随后被配置为使用代理服务器,我们称其为使用端口 8080 的 proxy.example.com,现在的请求有哪些不同?
显然请求现在发送到 proxy.example.com:8080,但肯定还有其他更改才能使代理向原始 url?
发出请求When making a request to a proxy, other than a CONNECT or server-wide OPTIONS request (as detailed below), a client MUST send the target URI in absolute-form as the request-target.
absolute-form = absolute-URI
The proxy is requested to either service that request from a valid cache, if possible, or make the same request on the client's behalf to either the next inbound proxy server or directly to the origin server indicated by the request-target. Requirements on such "forwarding" of messages are defined in Section 5.7.
An example absolute-form of request-line would be:
GET http://www.example.org/pub/WWW/TheProject.html HTTP/1.1
因此,在没有代理的情况下,连接到 www.example.org:80
:
GET /pub/WWW/TheProject.html HTTP/1.1
Host: www.example.org
使用代理服务器 proxy.example.com:8080
:
GET http://www.example.org/pub/WWW/TheProject.html HTTP/1.1
Host: www.example.org
在后一种情况下,Host
header 是可选的(对于 HTTP/1.0 客户端),无论如何都必须由代理重新计算。
代理只是代表原始客户端发出请求。因此名称 "proxy",与法律术语中的含义相同。浏览器将他们的请求发送给代理,代理向请求的服务器发出请求(或不请求,取决于代理是否要转发或拒绝此请求),服务器 returns 对代理的响应,代理 returns 对原始客户端的响应。服务器将看到的内容没有根本区别,除了原始客户端将显示为代理服务器这一事实。代理可能会也可能不会更改请求,它可能会也可能不会缓存它;这意味着如果代理决定交付缓存版本,服务器可能根本不会收到请求。