mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
05d02bdb3c
commit
33a4746dc6
@ -34,6 +34,9 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<Automatic-Module-Name>org.dromara.hutool.http</Automatic-Module-Name>
|
<Automatic-Module-Name>org.dromara.hutool.http</Automatic-Module-Name>
|
||||||
|
<httpclient5.version>5.4</httpclient5.version>
|
||||||
|
<httpclient4.version>4.5.14</httpclient4.version>
|
||||||
|
<okhttp.version>4.12.0</okhttp.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -81,19 +84,19 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||||
<artifactId>httpclient5</artifactId>
|
<artifactId>httpclient5</artifactId>
|
||||||
<version>5.2.1</version>
|
<version>${httpclient5.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
<version>4.5.14</version>
|
<version>${httpclient4.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<version>4.12.0</version>
|
<version>${okhttp.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class JdkClientEngine extends AbstractClientEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initEngine() {
|
protected void initEngine() {
|
||||||
this.cookieManager = this.config.isUseCookieManager() ? new JdkCookieManager() : new JdkCookieManager(null);
|
this.cookieManager = (null != this.config && this.config.isUseCookieManager()) ? new JdkCookieManager() : new JdkCookieManager(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,7 +160,8 @@ public class JdkClientEngine extends AbstractClientEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null == message.header(HeaderName.COOKIE)) {
|
// Cookie管理
|
||||||
|
if (null == message.header(HeaderName.COOKIE) && null != this.cookieManager) {
|
||||||
// 用户没有自定义Cookie,则读取Cookie管理器中的信息并附带到请求中
|
// 用户没有自定义Cookie,则读取Cookie管理器中的信息并附带到请求中
|
||||||
// 不覆盖模式回填Cookie头,这样用户定义的Cookie将优先
|
// 不覆盖模式回填Cookie头,这样用户定义的Cookie将优先
|
||||||
conn.header(this.cookieManager.loadForRequest(conn), false);
|
conn.header(this.cookieManager.loadForRequest(conn), false);
|
||||||
|
@ -272,7 +272,9 @@ public class JdkHttpResponse implements Response, Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 存储服务端设置的Cookie信息
|
// 存储服务端设置的Cookie信息
|
||||||
this.cookieManager.saveFromResponse(this.httpConnection, this.headers);
|
if(null != this.cookieManager){
|
||||||
|
this.cookieManager.saveFromResponse(this.httpConnection, this.headers);
|
||||||
|
}
|
||||||
|
|
||||||
// 获取响应内容流
|
// 获取响应内容流
|
||||||
if (!isIgnoreBody) {
|
if (!isIgnoreBody) {
|
||||||
|
@ -135,7 +135,7 @@ public class OkHttpEngine extends AbstractClientEngine {
|
|||||||
setProxy(builder, config);
|
setProxy(builder, config);
|
||||||
|
|
||||||
// Cookie管理
|
// Cookie管理
|
||||||
if (this.config.isUseCookieManager()) {
|
if (null != this.config && this.config.isUseCookieManager()) {
|
||||||
this.cookieStore = new InMemoryCookieStore();
|
this.cookieStore = new InMemoryCookieStore();
|
||||||
builder.cookieJar(new CookieJarImpl(this.cookieStore));
|
builder.cookieJar(new CookieJarImpl(this.cookieStore));
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.ofdrw</groupId>
|
<groupId>org.ofdrw</groupId>
|
||||||
<artifactId>ofdrw-full</artifactId>
|
<artifactId>ofdrw-full</artifactId>
|
||||||
<version>2.3.1</version>
|
<version>2.3.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user