简体   繁体   English

Java代码检查传入请求的HTTP标头

[英]Java code to check HTTP headers for incoming request

I want to detect if there is any kind of vulnerable data present in the incoming request and only if the request headers looks okay it will taken by the server else it wil be deny by the server. 我想检测传入的请求中是否存在任何易受攻击的数据,并且仅当请求标头看起来正常时,它才会被服务器占用,否则它将被服务器拒绝。

Also it would be if anybody could provide like to any opensource tools which already provide those. 同样,如果有人可以向已经提供这些工具的任何开源工具提供类似的工具。 I am doing this to minimise already existing DOS attacks. 我这样做是为了最小化已经存在的DOS攻击。

You can implement a javax.servlet.Filter and configure it in the web.xml file ( <filter> and <filter-mapping> tags). 您可以实现javax.servlet.Filter并在web.xml文件( <filter><filter-mapping>标记)中对其进行配置。 That will allow you to execute code on an incoming request to some (or all) your URLs and decide what to do, if normal processing, alternate processing, or simply nothing. 这样一来,您就可以在对某些(或全部)URL的传入请求上执行代码,并决定要执行的操作(是正常处理,替代处理还是什么都不做)。

Just implement the doFilter method and if you want to let the request/response pair continue its processing, call chain.doFilter(req, resp) . 只需实现doFilter方法,如果您想让请求/响应对继续其处理,请调用chain.doFilter(req, resp) Also you can provide request or response wrappers to the chain. 您也可以为链提供请求或响应包装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM