Indy的TIdHTTPProxyServer:如何过滤请求? [英] Indy's TIdHTTPProxyServer: How to filter requests?

查看:59
本文介绍了Indy的TIdHTTPProxyServer:如何过滤请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TIdHTTPProxyServer来实现简单的HTTP代理,但是现在我想阻止某些连接(如果它们匹配某些URL)。哪个事件和/或组件最适合完成此任务? Indy文档不是太明确。 :(

I'm using an TIdHTTPProxyServer to implement a simple HTTP proxy, but I'd like now to block some connections if they match certain URLs. Which event and/or component is best to accomplish that? Indy documentation is not too explicative. :(

谢谢!

推荐答案

作为基本过滤器,您可以使用OnHTTPBeforeCommand事件处理程序(在将命令发送到HTTP服务器之前触发)。

As a basic filter you can use the OnHTTPBeforeCommand event handler (which fires before the command is sent to the HTTP server).

检查Context参数属性,您会发现很有用:

Inspect the Context parameter properties, you'll find useful:

Context.Command
Context.OutboundClient.Host
Context.OutboundClient.Port
Context.Document
Context.Headers

目前我从未尝试过停止PassTrough,但是我敢打赌如果您确定存在阻止规则匹配,则只需在此时提出异常即可。

I never tried to stop the PassTrough at this time, but I bet you can do it by just raising an exception at that point if you determine there's a block rule match.

这篇关于Indy的TIdHTTPProxyServer:如何过滤请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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