我试图通过Android的HttpURLConnection
(从org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection
导入)发送GET请求,在接收响应时,会抛出一个IOException:
在doRequestInternal()中:“接收到的身份验证挑战为null”
这个错误是什么意思,是什么导致了这个错误?我正在将OAuth参数写入Authorization标头,但我在其他情况下也会这样做,没有问题。
if (connection == null) {
connection = (HttpURLConnection) new URL(endpointUrl).openConnection();
connection.setRequestMethod("GET");
}
//... do some OAuth message signing
connection.connect();
int statusCode = connection.getResponseCode(); // throws IOException