mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 23:41:09 -04:00
Android: Try to fix 'unexpected status line' errors with texture packs from dropbox, addresses #933
This commit is contained in:
parent
c4fe212b8b
commit
8e61dbc18a
@ -811,11 +811,24 @@ public class MainActivity extends Activity
|
|||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
conn.setRequestMethod(method);
|
conn.setRequestMethod(method);
|
||||||
conn.setInstanceFollowRedirects(true);
|
conn.setInstanceFollowRedirects(true);
|
||||||
|
|
||||||
|
httpAddMethodHeaders(method);
|
||||||
return 0;
|
return 0;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return httpOnError(ex);
|
return httpOnError(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void httpAddMethodHeaders(String method) {
|
||||||
|
if (!method.equals("HEAD")) return;
|
||||||
|
|
||||||
|
// Ever since dropbox switched to to chunked transfer encoding,
|
||||||
|
// sending a HEAD request to dropbox always seems to result in the
|
||||||
|
// next GET request failing with 'Unexpected status line' ProtocolException
|
||||||
|
// Seems to be a known issue: https://github.com/square/okhttp/issues/3689
|
||||||
|
// Simplest workaround is to ask for connection to be closed after HEAD request
|
||||||
|
httpSetHeader("connection", "close");
|
||||||
|
}
|
||||||
|
|
||||||
public static void httpSetHeader(String name, String value) {
|
public static void httpSetHeader(String name, String value) {
|
||||||
conn.setRequestProperty(name, value);
|
conn.setRequestProperty(name, value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user