0

当我尝试下载大约 900 MB 的文件时,当我暂停下载并在一段时间后重试时(比如几个小时)。Chrome 而不是恢复下载只是将文件标记为已完成。

 public HttpURLConnection getConnection(String url, METHOD method)
            throws IOException, SocketException {
        URL server = new URL(url);
        HttpURLConnection httpsconnection = (HttpURLConnection) server.openConnection();
        if (method == METHOD.POST) {
            httpsconnection.setRequestMethod("POST"); //No i18N
            httpsconnection.setFixedLengthStreamingMode(0);
        } else if (method == METHOD.GET) {
            httpsconnection.setRequestMethod("GET"); //No i18N
        }
        httpsconnection.setDoInput(true);
        httpsconnection.setDoOutput(true);
        httpsconnection.setInstanceFollowRedirects(false);
        httpsconnection.setRequestProperty("connection","keep-alive"); //No i18N
        httpsconnection.setRequestProperty("content-length","0"); //No i18N
        httpsconnection.setConnectTimeout(4000);
        httpsconnection.setReadTimeout(30000);
        return httpsconnection;
    }

我是否缺少要在标头值中设置的内容。当我尝试从其他网站下载文件时,他们只是说“网络 - 已断开连接”并暂停下载,一段时间后可以恢复。

只是好奇这个暂停和恢复如何与 chrome 一起工作。我的浏览器客户端(如 Chrome、Firefox)如何知道网络中断。有人可以启发我吗?

4

0 回答 0