如何创建在C#中一个简单的代理?简单

由网友(学会抛开过去)分享简介:我已经下载Privoxy的几个星期前,为了好玩我很好奇,想知道它的一个简单的版本可以做到的。I have downloaded Privoxy few weeks ago and for the fun I was curious to know how a simple version of it can be d...

我已经下载Privoxy的几个星期前,为了好玩我很好奇,想知道它的一个简单的版本可以做到的。

I have downloaded Privoxy few weeks ago and for the fun I was curious to know how a simple version of it can be done.

我知道我需要配置浏览器(客户端)请求发送到代理。代理请求发送到Web(让我们说这是一个HTTP代理)。代理将获得答案...但如何才能代理发送回请求浏览器(客户端)?

I understand that I need to configure the browser (client) to send request to the proxy. The proxy send the request to the web (let say it's a http proxy). The proxy will receive the answer... but how can the proxy send back the request to the browser (client)?

我在网上搜索C#和HTTP代理上,但还没有找到的东西,让我明白它是如何工作的幕后正确。 (我相信我不想一个反向代理,但我不知道)。

I have search on the web for C# and http proxy but haven't found something that let me understand how it works behind the scene correctly. (I believe I do not want a reverse proxy but I am not sure).

请问你们有一些解释或某些信息,这将让我继续这个小项目?

Does any of you have some explication or some information that will let me continue this small project?

这是我的理解(见下图)。

This is what I understand (see graphic below).

第1步我配置客户端(浏览器),用于将发送所有的请求到127.0.0.1在港口代理听。通过这种方式,请求将不被发送到因特网直接但会由代理来处理。

Step 1 I configure the client (browser) for all request to be send to 127.0.0.1 at the port the Proxy listen. This way, request will be not sent to the Internet directly but will be processed by the proxy.

第二步:代理看到一个新的联接,读取HTTP头,看到了要求他必须执行时。他执行的请求。

Step2 The proxy see a new connexion, read the HTTP header and see the request he must executes. He executes the request.

第三步:代理收到请求的应答。现在,他必须从网络上发送答案的客户端,但如何???

Step3 The proxy receive an answer from the request. Now he must send the answer from the web to the client but how???

颏代理的:我发现这个项目是一个代理(但更多的,我想) 。我可能会检查源,但我真的想要的东西基本了解更多的概念。

Mentalis Proxy : I have found this project that is a proxy (but more that I would like). I might check the source but I really wanted something basic to understand more the concept.

ASP代理:我也许能挺过来了一些信息太

ASP Proxy : I might be able to get some information over here too.

Request反射:这是一个简单的例子

Request reflector : This is a simple example.

下面是一个的Git仓库中心用简单的HTTP代理。

推荐答案

您可以建立一个具有HttpListener类来侦听传入的请求和HttpWebRequest一流的中继请求。

You can build one with the HttpListener class to listen for incoming requests and the HttpWebRequest class to relay the requests.

阅读全文

相关推荐

最新文章