如何在Java中修改X-Forwarded-For标头?

时间:2012-07-16 23:24:58

标签: java

我使用URLConnection连接到网站。我使用System.getProperties()设置proxyHostproxyPort,以及connection.setRequestProperty来更改用户代理。我还没有找到改变X-Forwarded-For的方法。

有人可以启发我吗?

谢谢!

1 个答案:

答案 0 :(得分:3)

尝试以下方法:

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

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