mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
05d02bdb3c
commit
33a4746dc6
@ -34,6 +34,9 @@
|
||||
|
||||
<properties>
|
||||
<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>
|
||||
|
||||
<dependencies>
|
||||
@ -81,19 +84,19 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<version>5.2.1</version>
|
||||
<version>${httpclient5.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.14</version>
|
||||
<version>${httpclient4.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
<version>${okhttp.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class JdkClientEngine extends AbstractClientEngine {
|
||||
|
||||
@Override
|
||||
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将优先
|
||||
conn.header(this.cookieManager.loadForRequest(conn), false);
|
||||
|
@ -272,7 +272,9 @@ public class JdkHttpResponse implements Response, Closeable {
|
||||
}
|
||||
|
||||
// 存储服务端设置的Cookie信息
|
||||
this.cookieManager.saveFromResponse(this.httpConnection, this.headers);
|
||||
if(null != this.cookieManager){
|
||||
this.cookieManager.saveFromResponse(this.httpConnection, this.headers);
|
||||
}
|
||||
|
||||
// 获取响应内容流
|
||||
if (!isIgnoreBody) {
|
||||
|
@ -135,7 +135,7 @@ public class OkHttpEngine extends AbstractClientEngine {
|
||||
setProxy(builder, config);
|
||||
|
||||
// Cookie管理
|
||||
if (this.config.isUseCookieManager()) {
|
||||
if (null != this.config && this.config.isUseCookieManager()) {
|
||||
this.cookieStore = new InMemoryCookieStore();
|
||||
builder.cookieJar(new CookieJarImpl(this.cookieStore));
|
||||
}
|
||||
|
@ -58,7 +58,7 @@
|
||||
<dependency>
|
||||
<groupId>org.ofdrw</groupId>
|
||||
<artifactId>ofdrw-full</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<version>2.3.3</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
Loading…
x
Reference in New Issue
Block a user