我有一个需要在连接中设置请求属性的 Android 应用程序。这是我的代码:
URL url = new URL(sUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("cookie", cookievalue);
connection.connect();
当我调用该setRequestProperty
方法时,它会启动异常:
java.lang.IllegalStateException: Cannot set request property after connection is made
有没有办法在不使用的情况下创建到文件的连接url.openConnection()
?