mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
CookieManager parses the cookie header even if we ask to ignore them, use our own cookie handler that does nothing
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
package com.commafeed.backend;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.CookieManager;
|
||||
import java.net.CookiePolicy;
|
||||
import java.net.CookieHandler;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpClient.Redirect;
|
||||
@@ -10,6 +9,9 @@ import java.net.http.HttpClient.Version;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -117,10 +119,23 @@ public class HttpGetter {
|
||||
.followRedirects(Redirect.ALWAYS)
|
||||
.sslContext(sslFactory.getSslContext())
|
||||
.sslParameters(sslFactory.getSslParameters())
|
||||
.cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_NONE))
|
||||
.cookieHandler(new IgnoreCookieHandler())
|
||||
.build();
|
||||
}
|
||||
|
||||
private static class IgnoreCookieHandler extends CookieHandler {
|
||||
@Override
|
||||
public Map<String, List<String>> get(URI uri, Map<String, List<String>> requestHeaders) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(URI uri, Map<String, List<String>> responseHeaders) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class NotModifiedException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
Reference in New Issue
Block a user