Skip to content

Commit

Permalink
remove: 去除403后的无效尝试
Browse files Browse the repository at this point in the history
  • Loading branch information
nICEnnnnnnnLee committed Jun 29, 2024
1 parent b82bc1b commit 91a1fe0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/nicelee/bilibili/util/HttpRequestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ public boolean download(String url, String fileName, HashMap<String, String> hea
HttpURLConnection conn = connect(headers, urlNameString, null);
conn.connect();

if (conn.getResponseCode() == 403) {
Logger.println("403被拒,尝试更换Headers");
conn.disconnect();
headers = HttpHeaders.getBiliAppDownHeaders();
offset = modifyHeaderMapByDownloaded(headers, raf, fileDownloadPart, offset);
conn = connect(headers, urlNameString, null);
conn.connect();
}
// if (conn.getResponseCode() == 403) {
// Logger.println("403被拒,尝试更换Headers");
// conn.disconnect();
// headers = HttpHeaders.getBiliAppDownHeaders();
// offset = modifyHeaderMapByDownloaded(headers, raf, fileDownloadPart, offset);
// conn = connect(headers, urlNameString, null);
// conn.connect();
// }
// 获取所有响应头字段
Map<String, List<String>> map = conn.getHeaderFields();
// 遍历所有的响应头字段
Expand Down
18 changes: 9 additions & 9 deletions src/nicelee/bilibili/util/HttpRequestUtilEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public void run() {
// 开始下载
HttpURLConnection conn = connect(specificHeader, url, null);
conn.connect();
if (conn.getResponseCode() == 403) {
Logger.println("403被拒,尝试更换Headers");
conn.disconnect();
specificHeader.clear();
specificHeader.putAll(HttpHeaders.getBiliAppDownHeaders());
specificHeader.put("range", String.format(range, min + offset, max));
conn = connect(specificHeader, url, null);
conn.connect();
}
// if (conn.getResponseCode() == 403) {
// Logger.println("403被拒,尝试更换Headers");
// conn.disconnect();
// specificHeader.clear();
// specificHeader.putAll(HttpHeaders.getBiliAppDownHeaders());
// specificHeader.put("range", String.format(range, min + offset, max));
// conn = connect(specificHeader, url, null);
// conn.connect();
// }
// 获取所有响应头字段
// Map<String, List<String>> map = conn.getHeaderFields();
// Logger.println("Content-Range" + map.get("Content-Range"));
Expand Down

0 comments on commit 91a1fe0

Please sign in to comment.