Cynthia Good
Cynthia Good

Reputation: 11

How do I modify the X-Forwarded-For header in Java?

I'm using URLConnection to connect to a site. I used System.getProperties() to set the proxyHost and proxyPort, and connection.setRequestProperty to change the user-agent. I haven't seen a way to change the X-Forwarded-For.

Can someone enlighten me?

Thanks!

Upvotes: 1

Views: 3421

Answers (1)

Ram G
Ram G

Reputation: 4829

Try the below:

 connection.addRequestProperty("X-Forwarded-For",VALUE-IP);

Reference: http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URLConnection.html#addRequestProperty(java.lang.String, java.lang.String)

Upvotes: 3

Related Questions