Skip to content

Tag: proxy

Java ProxySelector undefined behaviour

I am experimenting with Proxies in java networking. I have read the documentation regarding them and am currently testing ProxySelector. I notice 2 types of behaviour of this ProxySelector when using with HttpURLConnection & when using with Socket class When using with HttpUrlConnection with this code I g…

Java littleproxy mitm: getting response body

I am trying to use littleproxy-mitm to inspect traffic. I have access to the headers and can easily read them. However, I cant find the body of a response consitently. To see if I can get the body I am using this testing my app by visiting https://www.google.com/humans.txt, but the wanted body is no where to …

Java Using proxy settings in jar

I’m doing a webscraping with jar i created, which uses a proxy. My question is that i have large project where more webscrapers will work in paralel. Using this code: will affect the others webscrapers? Answer If you run them as separate processes, then each process has its own system properties. If you…

How to get response body in Zuul post filter?

How it is possible to read a response body while using Zuul as a proxy in post filter? I am trying to call the code like this: Answer I’ve managed to overcome this. The solution consists of 4 steps: Read ctx.getResponseDataStream() into a ByteArrayOutputStream Copy OutputStream to 2 InputStreams. Use on…

Authenticated HTTP proxy with Java

How can I configure the username and password to authenticate a http proxy server using Java? I just found the following configuration parameters: But, my proxy server requires authentication. How can I configure my app to use the proxy server? Answer (EDIT: As pointed out by the OP, the using a java.net.Auth…

How do I make HttpURLConnection use a proxy?

If I do this… it prints The problem is, I am behind a proxy. Where does the JVM get its proxy information from on Windows? How do I set this up? All my other apps seem perfectly happy with my proxy. Answer Since java 1.5 you can also pass a java.net.Proxy instance to the openConnection(proxy) method: If…