我需要一个响应代码,但它抛出一个IOException.我不知道发生了什么事!
try
{
url = new URL(urlBuilder.toString());
conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setConnectTimeout(TIME_OUT);
conn.setRequestMethod(METHOD_GET);
conn.setRequestProperty("accept", "*/*");
conn.connect();
int responseCode = conn.getResponseCode(); //throw IOException:Received authentication challenge is null
if (responseCode == HTTP_OK)
{
inStream = conn.getInputStream();
response = getResponse(inStream);
}
else
{
response = "response code?"+responseCode;
}
} catch (Exception e)
{
throw e;
}
finally
{
conn.disconnect();
}
return response;
}
Run Code Online (Sandbox Code Playgroud)
IOException是:
05-03 20:14:01.577: WARN/System.err(1515): java.io.IOException: Received authentication challenge is null
05-03 20:14:01.596: WARN/System.err(1515): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.doRequestInternal(HttpURLConnectionImpl.java:1694)
05-03 20:14:01.577: INFO/QQWeiBo(1515): Received …Run Code Online (Sandbox Code Playgroud)