add: useragent - if domain suffix
This commit is contained in:
parent
6d5aaad7f1
commit
743483fdfb
|
@ -84,8 +84,20 @@ public final class NetworkUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static boolean endsWithDomainSuffix(String host, String domainSuffix) {
|
||||
return host.endsWith(domainSuffix.toLowerCase());
|
||||
}
|
||||
|
||||
public static URLConnection createConnection(URL url) throws IOException {
|
||||
URLConnection connection = url.openConnection();
|
||||
String host = url.getHost().toLowerCase();
|
||||
if (endsWithDomainSuffix(host, "d.pcs.baidu.com") || endsWithDomainSuffix(host, "baidupcs.com")) {
|
||||
// Docs: https://alist.nn.ci/zh/guide/drivers/baidu.html
|
||||
connection.setRequestProperty("User-Agent", "pan.baidu.com");
|
||||
} else {
|
||||
// Default
|
||||
connection.setRequestProperty("User-Agent", "FCL/1.1.3");
|
||||
}
|
||||
connection.setUseCaches(false);
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.setReadTimeout(5000);
|
||||
|
|
Loading…
Reference in New Issue