import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultRedirectStrategy;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.protocol.HttpContext;
public class Main {
public static void main(String[] args) {
HttpClient httpClient = HttpClients.custom()
.setRedirectStrategy(new DefaultRedirectStrategy() {
@Override
public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException {
boolean isRedirected = super.isRedirected(request, response, context);
if (!isRedirected) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 301 || statusCode == 302) {
return true;
}
}
return isRedirected;
}
})
.build();
}
}
aW1wb3J0IG9yZy5hcGFjaGUuaHR0cC5IdHRwUmVxdWVzdDsKaW1wb3J0IG9yZy5hcGFjaGUuaHR0cC5IdHRwUmVzcG9uc2U7CmltcG9ydCBvcmcuYXBhY2hlLmh0dHAuUHJvdG9jb2xFeGNlcHRpb247CmltcG9ydCBvcmcuYXBhY2hlLmh0dHAuY2xpZW50Lkh0dHBDbGllbnQ7CmltcG9ydCBvcmcuYXBhY2hlLmh0dHAuaW1wbC5jbGllbnQuRGVmYXVsdFJlZGlyZWN0U3RyYXRlZ3k7CmltcG9ydCBvcmcuYXBhY2hlLmh0dHAuaW1wbC5jbGllbnQuSHR0cENsaWVudHM7CmltcG9ydCBvcmcuYXBhY2hlLmh0dHAucHJvdG9jb2wuSHR0cENvbnRleHQ7CgpwdWJsaWMgY2xhc3MgTWFpbiB7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CgkJSHR0cENsaWVudCBodHRwQ2xpZW50ID0gSHR0cENsaWVudHMuY3VzdG9tKCkKCQkJCS5zZXRSZWRpcmVjdFN0cmF0ZWd5KG5ldyBEZWZhdWx0UmVkaXJlY3RTdHJhdGVneSgpIHsKCQkJCQlAT3ZlcnJpZGUKCQkJCQlwdWJsaWMgYm9vbGVhbiBpc1JlZGlyZ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