pull/171/head
FongMi 2 years ago
parent a37125b001
commit 12e38108f4
  1. 4
      app/src/main/java/com/fongmi/android/tv/server/process/Local.java
  2. 3
      app/src/main/java/com/fongmi/android/tv/utils/Download.java

@ -127,8 +127,8 @@ public class Local implements Process {
if (headerIfRangeMissingOrMatching && range != null && startFrom >= 0 && startFrom < fileLen) {
if (headerIfNoneMatchPresentAndMatching) {
res = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.NOT_MODIFIED, mime, "");
res.addHeader("Accept-Ranges", "bytes");
res.addHeader("ETag", etag);
res.addHeader(HttpHeaders.ACCEPT_RANGES, "bytes");
res.addHeader(HttpHeaders.ETAG, etag);
} else {
if (endAt < 0) endAt = fileLen - 1;
long newLen = endAt - startFrom + 1;

@ -3,6 +3,7 @@ package com.fongmi.android.tv.utils;
import com.fongmi.android.tv.App;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Path;
import com.google.common.net.HttpHeaders;
import java.io.BufferedInputStream;
import java.io.File;
@ -41,7 +42,7 @@ public class Download {
try {
Path.clear(file);
Response response = OkHttp.newCall(url).execute();
download(response.body().byteStream(), Double.parseDouble(response.header("Content-Length", "1")));
download(response.body().byteStream(), Double.parseDouble(response.header(HttpHeaders.CONTENT_LENGTH, "1")));
if (callback != null) App.post(() -> callback.success(Path.chmod(file)));
} catch (Exception e) {
if (callback != null) App.post(() -> callback.error(e.getMessage()));

Loading…
Cancel
Save