pull/586/head
FongMi 12 months ago
parent 4e8ef693bd
commit 83689bbcea
  1. 4
      catvod/src/main/java/com/github/catvod/net/OkCookieJar.java
  2. 3
      catvod/src/main/java/com/github/catvod/net/interceptor/RequestInterceptor.java

@ -59,7 +59,7 @@ public class OkCookieJar implements CookieJar {
List<Cookie> items = new ArrayList<>();
String cookie = manager.getCookie(url.toString());
if (TextUtils.isEmpty(cookie)) return Collections.emptyList();
if (url.host().equals("127.0.0.1")) return Collections.emptyList();
if ("127.0.0.1".equals(url.host())) return Collections.emptyList();
for (String split : cookie.split(";")) add(items, Cookie.parse(url, split));
return items;
} catch (Throwable e) {
@ -70,7 +70,7 @@ public class OkCookieJar implements CookieJar {
@Override
public synchronized void saveFromResponse(@NonNull HttpUrl url, @NonNull List<Cookie> cookies) {
try {
if (url.host().equals("127.0.0.1")) return;
if ("127.0.0.1".equals(url.host())) return;
for (Cookie cookie : cookies) manager.setCookie(url.toString(), cookie.toString());
} catch (Throwable ignored) {
}

@ -43,9 +43,10 @@ public class RequestInterceptor implements Interceptor {
private void checkAuthUser(HttpUrl url, Request.Builder builder) {
String user = url.uri().getUserInfo();
String auth = url.queryParameter("auth");
String query = url.querySize() == 0 ? "?" : "&";
if (user != null) userMap.put(url.host(), user);
if (auth != null) authMap.put(url.host(), auth);
if (authMap.containsKey(url.host()) && auth == null) builder.url(url + "&auth=" + authMap.get(url.host()));
if (authMap.containsKey(url.host()) && auth == null) builder.url(url + query + "auth=" + authMap.get(url.host()));
if (userMap.containsKey(url.host())) builder.header(HttpHeaders.AUTHORIZATION, Util.basic(userMap.get(url.host())));
}
}

Loading…
Cancel
Save