Bug #458
getResponseCode returns -1
| Status: | Resolved | Start date: | 06/02/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | 0.1b |
Description
For https websites, getResponseCode on a httpurlconnection returns -1 even though it should return a proper code.
This might be an internal Android Java bug.
History
Updated by Zubair Nabi almost 2 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Replacing:
HttpURLConnection httpURLConnection
= (HttpURLConnection) urlConnection;
return httpURLConnection.getResponseCode();
with:
HttpGet httpGet = new HttpGet(str);
HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet);
return httpResponse.getStatusLine().getStatusCode();
seems to have solved the problem.
Updated by Adriano Marques over 1 year ago
- Target version set to 0.1b