开发者

Is there a possibility to manipulate the raw http-stream from within apache tomcat?

开发者 https://www.devze.com 2023-01-22 15:15 出处:网络
An application which consumes my webservice sends an invalid soap-request, my service can not handle this request.

An application which consumes my webservice sends an invalid soap-request, my service can not handle this request.

The applications send an wrong tag (misspelled), but they cannot alter this behaviour.

So my question:

Is there a possibility with a fil开发者_JAVA百科ter or a listner to get the raw http stream, alter something and put it back into the chain.

Thank you, Alex


I assume you want to change incoming body of the HTTP request. There is no easy way to do this. I don't know of any Servlet API that would allow you to do this "officially".

"Unofficially" you can do some reflection magic on org.apache.catalina.connector.Request. If you look at this object, you will see that both methods which return the actual body (getReader() and getInputStream()) are building streams on top of input buffer, instance of org.apache.catalina.connector.InputBuffer. You would have to manipulate that buffer so it returns tainted data.

Needless to say, this is a very volatile and dangerous hack. There are no guarantees this will work on the next Tomcat version (even minor one) and would be virtually unmaintainable.

0

精彩评论

暂无评论...
验证码 换一张
取 消