What exactly does URLConnection.setDoOutput() affect?

You need to set it to true if you want to send (output) a request body, for example with POST or PUT requests. With GET, you do not usually send a body, so you do not need it.

Sending the request body itself is done via the connection’s output stream:

conn.getOutputStream().write(someBytes);

Leave a Comment