如何使用TIdHTTPProxyServer(代理链)将请求转发到另一个代理服务器 [英] How do I forward request to another proxy server using TIdHTTPProxyServer (proxy chain)
本文介绍了如何使用TIdHTTPProxyServer(代理链)将请求转发到另一个代理服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前,我想让我的Indy代理服务器将请求转发到另一个代理服务器。我找到了此链接,并亲自尝试了一下。但是,如果没有任何错误消息,我的代码将无法正常工作,就像我没有进行任何更改一样。我的代码如下在C ++ XE2中。
currently I want to make my indy proxy server forward the request to another proxy server. I have found this link and made a try by myself. But my code does not work without any error message as if I had made no change. My code is as below in C++ XE2.
void __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext)
{
TIdIOHandlerStack* tempIO = new TIdIOHandlerStack(NULL);
TIdConnectThroughHttpProxy* tempProxy = new TIdConnectThroughHttpProxy(NULL);
tempProxy->Enabled = true;
tempProxy->Host = "localhost";
tempProxy->Port = 8181 ;
tempIO->TransparentProxy = tempProxy;
AContext->OutboundClient->IOHandler = tempIO;
}
推荐答案
最后我发现我做了一些愚蠢的事情。正确的代码应如下所示……
Finally I found I did something stupid. The correct code should be as follow...
void __fastcall TForm3::MyProxyHTTPBeforeCommand(TIdHTTPProxyServerContext *AContext)
{
TIdIOHandlerStack* tempIO = new TIdIOHandlerStack(AContext->OutboundClient);
TIdConnectThroughHttpProxy* tempProxy = new TIdConnectThroughHttpProxy(AContext->OutboundClient);
tempProxy->Enabled = true;
tempProxy->Host = "localhost";
tempProxy->Port = 8181 ;
tempIO->TransparentProxy = tempProxy;
AContext->OutboundClient->IOHandler = tempIO;
这篇关于如何使用TIdHTTPProxyServer(代理链)将请求转发到另一个代理服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文