Intercept all outgoing java HTTP calls

Similar to HttpFilter (javax.Servlet.Filter) which when added to web.xml can intercept any incoming request to JVM / outgoing (as response) regardless of framework (Spring / CXF / Jersy etc.), I am trying to find the API which could intercept any outgoing HTTP calls from the JVM to add / change headers regardless of the framework. Also routing requests through a proxy sounds overwhelming.

Quite often the word "Outbound HTTP Call" is misinterpreted in the forums, so let me explain with an example.

Let's assume there are two JVMs, jvm1 and jvm2. and HTTP calls are made from JVM1 to JVM2. I would like to intercept an HTTP connection made from JVM1 to change the header information before the call. I don't want the code to bind to a specific structure, so I could bind the interceptor as a jar and share it with the application team. Changes to web.xml are ok.

Any suggestions? Please, help!

+3


source to share


2 answers


Both JVMs can use java.net.Socket

or in java.net.ServerSocket

some way to communicate and there is no way to intercept anything here.



You can intercept any HTTP traffic as long as you connect through a (transparent) proxy . The proxy will intercept anything and you can change any content.

+1


source


We went with an aspect. Not the best solution, but the only option we got.



0


source







All Articles