Tuesday, September 11, 2001 10:25 PM
The code for getOutputStream() in sun.net.www.protocol.http.HttpURLConnection includes the following line:
if (method.equals("GET")) this.setRequestMethod("POST");
In fact, if you use anything but POST or PUT (or GET, which is converted to POST for you), it will throw a ProtocolException with the message "HTTP method " + method + " doesn't support output".
The reason for this is that PUT and POST are the only HTTP request methods that can include a body. With other methods, the server might puke, but more likely would just ignore the body and read only the headers.
This begs the question, "why are you trying to add post data to a GET request?" Why not just implement doPost() and POST your request?