2

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)

Raghavendra
  • 3,530
  • 1
  • 17
  • 18
Peter.Sun
  • 21
  • 3

1 Answers1

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