retrieve uncompressed file size in HEAD request

This commit is contained in:
Daniel Gultsch 2022-03-30 18:45:18 +02:00
parent eadb1e127b
commit 95e3a6769d

View file

@ -322,6 +322,7 @@ public class HttpDownloadConnection implements Transferable {
); );
final Request request = new Request.Builder() final Request request = new Request.Builder()
.url(URL.stripFragment(mUrl)) .url(URL.stripFragment(mUrl))
.addHeader("Accept-Encoding", "identity")
.head() .head()
.build(); .build();
mostRecentCall = client.newCall(request); mostRecentCall = client.newCall(request);
@ -347,11 +348,11 @@ public class HttpDownloadConnection implements Transferable {
throw new IOException("Server reported negative file size"); throw new IOException("Server reported negative file size");
} }
return size; return size;
} catch (IOException e) { } catch (final IOException e) {
Log.d(Config.LOGTAG, "io exception during HEAD " + e.getMessage()); Log.d(Config.LOGTAG, "io exception during HEAD " + e.getMessage());
throw e; throw e;
} catch (NumberFormatException e) { } catch (final NumberFormatException e) {
throw new IOException(); throw new IOException(e);
} }
} }