mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-30 12:47:58 +08:00
fix bug
This commit is contained in:
parent
9eb95bf9d7
commit
cf5c9793ea
@ -206,9 +206,9 @@ public interface HeaderOperation<T extends HeaderOperation<T>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取内容编码
|
* 获取压缩媒体类型
|
||||||
*
|
*
|
||||||
* @return String
|
* @return 压缩媒体类型
|
||||||
*/
|
*/
|
||||||
default String contentEncoding() {
|
default String contentEncoding() {
|
||||||
return header(HeaderName.CONTENT_ENCODING);
|
return header(HeaderName.CONTENT_ENCODING);
|
||||||
|
@ -12,13 +12,12 @@
|
|||||||
|
|
||||||
package org.dromara.hutool.http.client.engine.httpclient4;
|
package org.dromara.hutool.http.client.engine.httpclient4;
|
||||||
|
|
||||||
|
import org.apache.http.entity.AbstractHttpEntity;
|
||||||
import org.dromara.hutool.http.client.body.BytesBody;
|
import org.dromara.hutool.http.client.body.BytesBody;
|
||||||
import org.dromara.hutool.http.client.body.HttpBody;
|
import org.dromara.hutool.http.client.body.HttpBody;
|
||||||
import org.apache.http.entity.AbstractHttpEntity;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link HttpBody}转换为{@link org.apache.hc.core5.http.HttpEntity}对象
|
* {@link HttpBody}转换为{@link org.apache.hc.core5.http.HttpEntity}对象
|
||||||
@ -34,14 +33,14 @@ public class HttpClient4BodyEntity extends AbstractHttpEntity {
|
|||||||
* 构造
|
* 构造
|
||||||
*
|
*
|
||||||
* @param contentType Content-Type类型
|
* @param contentType Content-Type类型
|
||||||
* @param charset 自定义请求编码
|
* @param contentEncoding 压缩媒体类型,如gzip、deflate等
|
||||||
* @param chunked 是否块模式传输
|
* @param chunked 是否块模式传输
|
||||||
* @param body {@link HttpBody}
|
* @param body {@link HttpBody}
|
||||||
*/
|
*/
|
||||||
public HttpClient4BodyEntity(final String contentType, final Charset charset, final boolean chunked, final HttpBody body) {
|
public HttpClient4BodyEntity(final String contentType, final String contentEncoding, final boolean chunked, final HttpBody body) {
|
||||||
super();
|
super();
|
||||||
setContentType(contentType);
|
setContentType(contentType);
|
||||||
setContentEncoding(null == charset ? null : charset.name());
|
setContentEncoding(contentEncoding);
|
||||||
setChunked(chunked);
|
setChunked(chunked);
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
@ -158,8 +158,7 @@ public class HttpClient4Engine implements ClientEngine {
|
|||||||
requestBuilder.setEntity(new HttpClient4BodyEntity(
|
requestBuilder.setEntity(new HttpClient4BodyEntity(
|
||||||
// 用户自定义的内容类型
|
// 用户自定义的内容类型
|
||||||
message.header(HeaderName.CONTENT_TYPE),
|
message.header(HeaderName.CONTENT_TYPE),
|
||||||
// 用户自定义编码
|
message.contentEncoding(),
|
||||||
message.charset(),
|
|
||||||
message.isChunked(),
|
message.isChunked(),
|
||||||
body));
|
body));
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import org.dromara.hutool.http.client.body.HttpBody;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link HttpBody}转换为{@link org.apache.hc.core5.http.HttpEntity}对象
|
* {@link HttpBody}转换为{@link org.apache.hc.core5.http.HttpEntity}对象
|
||||||
@ -34,12 +33,12 @@ public class HttpClient5BodyEntity extends AbstractHttpEntity {
|
|||||||
* 构造
|
* 构造
|
||||||
*
|
*
|
||||||
* @param contentType Content-Type类型
|
* @param contentType Content-Type类型
|
||||||
* @param charset 自定义请求编码
|
* @param contentEncoding 压缩媒体类型,如gzip、deflate等
|
||||||
* @param chunked 是否块模式传输
|
* @param chunked 是否块模式传输
|
||||||
* @param body {@link HttpBody}
|
* @param body {@link HttpBody}
|
||||||
*/
|
*/
|
||||||
public HttpClient5BodyEntity(final String contentType, final Charset charset, final boolean chunked, final HttpBody body) {
|
public HttpClient5BodyEntity(final String contentType, final String contentEncoding, final boolean chunked, final HttpBody body) {
|
||||||
super(contentType, null == charset ? null : charset.name(), chunked);
|
super(contentType, contentEncoding, chunked);
|
||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,8 +157,7 @@ public class HttpClient5Engine implements ClientEngine {
|
|||||||
request.setEntity(new HttpClient5BodyEntity(
|
request.setEntity(new HttpClient5BodyEntity(
|
||||||
// 用户自定义的内容类型
|
// 用户自定义的内容类型
|
||||||
message.header(HeaderName.CONTENT_TYPE),
|
message.header(HeaderName.CONTENT_TYPE),
|
||||||
// 用户自定义编码
|
message.contentEncoding(),
|
||||||
message.charset(),
|
|
||||||
message.isChunked(),
|
message.isChunked(),
|
||||||
body));
|
body));
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public class OkHttpRequestBody extends okhttp3.RequestBody {
|
|||||||
this.body = body;
|
this.body = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MediaType contentType() {
|
public MediaType contentType() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -129,11 +129,11 @@ public enum HeaderName {
|
|||||||
*/
|
*/
|
||||||
WWW_AUTHENTICATE("WWW-Authenticate"),
|
WWW_AUTHENTICATE("WWW-Authenticate"),
|
||||||
/**
|
/**
|
||||||
* Cookie
|
* Set-Cookie
|
||||||
*/
|
*/
|
||||||
SET_COOKIE("Set-Cookie"),
|
SET_COOKIE("Set-Cookie"),
|
||||||
/**
|
/**
|
||||||
* Content-Encoding
|
* 压缩媒体类型:Content-Encoding
|
||||||
*/
|
*/
|
||||||
CONTENT_ENCODING("Content-Encoding"),
|
CONTENT_ENCODING("Content-Encoding"),
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user