什么时候应该在HTTP代理服务器上使用CONNECT和GET HTTP方法? [英] When should one use CONNECT and GET HTTP methods at HTTP Proxy Server?

查看:174
本文介绍了什么时候应该在HTTP代理服务器上使用CONNECT和GET HTTP方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个WebClient库.现在,我正在实现代理功能,因此我正在做一些研究,并且看到了一些使用CONNECT方法请求URL的代码.

I'm building a WebClient library. Now I'm implementing a proxy feature, so I am making some research and I saw some code using the CONNECT method to request a URL.

但是在我的Web浏览器中检查它时,它不使用CONNECT方法,而是调用GET方法.

But checking it within my web browser, it doesn't use the CONNECT method but calls the GET method instead.

所以我很困惑.什么时候应该同时使用两种方法?

So I'm confused. When I should use both methods?

推荐答案

CONNECT请求会敦促您的代理建立到远程端点的HTTP隧道. 通常用于SSL连接,尽管它也可以与HTTP一起使用(用于代理链接和隧道传输)

A CONNECT request urges your proxy to establish an HTTP tunnel to the remote end-point. Usually is it used for SSL connections, though it can be used with HTTP as well (used for the purposes of proxy-chaining and tunneling)

CONNECT www.google.com:443 

上面的行在端口443上打开了您的代理与www.google.com的连接. 此后,客户端发送的内容将由代理转发到www.google.com:443.

The above line opens a connection from your proxy to www.google.com on port 443. After this, content that is sent by the client is forwarded by the proxy to www.google.com:443.

如果用户尝试检索 http://www.google.com 页面,则代理可以发送完全相同的请求,并且代表他为他找回答案.

If a user tries to retrieve a page http://www.google.com, the proxy can send the exact same request and retrieve response for him, on his behalf.

使用SSL(HTTPS),只有两个远程端点可以理解请求,并且代理无法解密请求.因此,它所做的全部工作就是使用CONNECT打开该隧道,并使两个端点(Web服务器和客户端)直接相互通信.

With SSL(HTTPS), only the two remote end-points understand the requests, and the proxy cannot decipher them. Hence, all it does is open that tunnel using CONNECT, and lets the two end-points (webserver and client) talk to each other directly.

代理链接:

如果要链接2个代理服务器,则这是要发出的请求的顺序.

If you are chaining 2 proxy servers, this is the sequence of requests to be issued.

GET1 is the original GET request (HTTP URL)
CONNECT1 is the original CONNECT request (SSL/HTTPS URL or Another Proxy)

User Request ==CONNECT1==> (Your_Primary_Proxy ==CONNECT==> AnotherProxy-1 ... ==CONNECT==> AnotherProxy-n) ==GET1(IF is http)/CONNECT1(IF is https)==> Destination_URL

这篇关于什么时候应该在HTTP代理服务器上使用CONNECT和GET HTTP方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆