My code is like the following:
URLConnection cnx = address.openConnection(); cnx.setAllowUserInteraction(false); cnx.setDoOutput(true); cnx.addReque
The headers must be set prior to getting the InputStream to have any affect - an IllegalStateException will be thrown if the connection is already open.
InputStream
IllegalStateException
As far as the User-Agent header specifically, it should be sent if it has been set.
User-Agent
See the URLConnection JavaDoc.