If I want to send a request with HttpsURLConnection
.
Can I change "remote_addr
" in the header? (if I don't want to get response
,just want to send the request
to server)
Asked
Active
Viewed 1,628 times
2

Raghavendra
- 3,530
- 1
- 17
- 18

Peter.Sun
- 21
- 3
1 Answers
0
Of course you can:
URL myURL = new URL("theURLToRequestTo");
HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
myURLConnection.setRequestProperty("REMOTE_ADDR", myIPAddress); // Here you can put the IP you want
myURLConnection.setRequestMethod("GET"); // Or POST as needed
myURLConnection.setRequestProperty("CONTENT-TYPE", "application/x-www-form-urlencoded");
myURLConnection.setRequestProperty("CONTENT-LENGTH", "" + Integer.toString(postData.getBytes().length));
myURLConnection.setRequestProperty("CONTENT-LANGUAGE", "en-US");
myURLConnection.setUseCaches(false);
myURLConnection.setDoInput(true);
myURLConnection.setDoOutput(true);
Update
Look at this solution.

Community
- 1
- 1

GingerHead
- 8,130
- 15
- 59
- 93
-
But the server got my real ip in "REMOTE_ADDR" , Not the ip I put in header. – Peter.Sun Aug 31 '15 at 14:31