Android: Try to fix 'unexpected status line' errors with texture packs from dropbox, addresses #933

This commit is contained in:
UnknownShadow200 2022-02-23 23:24:47 +11:00
parent c4fe212b8b
commit 8e61dbc18a

View file

@ -811,11 +811,24 @@ public class MainActivity extends Activity
conn.setDoInput(true);
conn.setRequestMethod(method);
conn.setInstanceFollowRedirects(true);
httpAddMethodHeaders(method);
return 0;
} catch (Exception 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) {
conn.setRequestProperty(name, value);