mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix redirect
This commit is contained in:
parent
b393d0d8f0
commit
868a0e6c3c
@ -42,10 +42,6 @@ import java.util.List;
|
||||
public class JdkClientEngine implements ClientEngine {
|
||||
|
||||
private ClientConfig config;
|
||||
/**
|
||||
* 重定向次数计数器,内部使用
|
||||
*/
|
||||
private int redirectCount;
|
||||
|
||||
/**
|
||||
* 构造
|
||||
@ -164,8 +160,8 @@ public class JdkClientEngine implements ClientEngine {
|
||||
if (code != HttpURLConnection.HTTP_OK) {
|
||||
if (HttpStatus.isRedirected(code)) {
|
||||
message.url(getLocationUrl(message.handledUrl(), conn.header(HeaderName.LOCATION)));
|
||||
if (redirectCount < message.maxRedirectCount()) {
|
||||
redirectCount++;
|
||||
if (conn.redirectCount < message.maxRedirectCount()) {
|
||||
conn.redirectCount++;
|
||||
return send(message, isAsync);
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ public class JdkHttpConnection implements HeaderOperation<JdkHttpConnection>, Cl
|
||||
private final URL url;
|
||||
private final Proxy proxy;
|
||||
private final HttpURLConnection conn;
|
||||
/**
|
||||
* 重定向次数计数器,内部使用
|
||||
*/
|
||||
protected int redirectCount;
|
||||
|
||||
/**
|
||||
* 创建HttpConnection
|
||||
|
Loading…
x
Reference in New Issue
Block a user