I have an Android app that need to set a requestproperty in a connection. Here is my code:
URL url = new URL(sUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("cookie", cookievalue);
connection.connect();
When I call the setRequestProperty
method it launch the exception:
java.lang.IllegalStateException: Cannot set request property after connection is made
Is there a way to create the connection to the file without using the url.openConnection()
?