HttpURLConnection method is always GET?

Viewed 2385

As the Android documents indicate, I've set setDoOutPut(true); so that the connection sends as POST. However, in the debugger when I check the HTTPURLConnection method member, it is always GET, even after setDoOutput(true) and even setRequestMethod("POST"). Am I somehow resetting it back to GET?

URL url = new URL(serverAddr);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod(verb);
urlConnection.setFixedLengthStreamingMode(postBody.getBytes().length);
//urlConnection.setRequestProperty("Content-Length", postBody.getBytes().toString());
urlConnection.setRequestProperty("Content-Type", "application/json;charset=utf-8");

urlConnection.connect();

OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
out.write(postBody.getBytes());
out.flush();

int responseCode = urlConnection.getResponseCode();
System.out.println("HTTPS RESPONSE CODE: " + responseCode);

out.close();

EDIT: This has got to be a bug...the debugger shows setDoOuput member variable clearly as false even when I'm setting it to true. It's not being set!

2 Answers
Related