Skip to content
Advertisement

Tag: proxy

How to set proxy header in HttpURLConnection

I am trying to build an HTTP request to be sent via a proxy that accepts a proxy header. I am trying to find a way to set that, but couldn’t see it. Below is the curl command which I need to convert to the Java code. curl -i -u user:pwd -k GET –http1.1 –proxy-insecure https://localhost:8443 –proxy-header “X-Connect-Client-Id: abcde” https://target_host/api

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 get the expected output This makes sense because ports 5000 & 8000 are

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 be found. But when

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 are running them in one process as

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 one of it for your custom purposes. Use the second

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.Authenticator is required too. I’m updating my answer accordingly

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 your proxy requires

Advertisement