public final class WxApiHttpRequest extends Object implements org.springframework.http.client.ClientHttpRequest
| Constructor and Description |
|---|
WxApiHttpRequest(org.springframework.http.client.ClientHttpRequest delegate) |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.http.client.ClientHttpResponse |
execute() |
OutputStream |
getBody()
针对下面这个比较恶心的魔法逻辑的说明:
由于Spring5在对ContentType是MULTIPART_FORM_DATA的头处理时自动添加了charset参数。
see org.springframework.http.converter.FormHttpMessageConverter.writeMultipart
如果设置了multipartCharset,则不会添加charset参数。
但是在获取filename时又去判断如果设置了multipartCharset,则调用MimeDelegate.encode(filename, this.multipartCharset.name())
对filename进行encode,但是MimeDelegate调用了javax.mail.internet.MimeUtility这个类,这个类有可能没有被依赖进来,不是强依赖的
故会导致一样的报错。实在没办法切入源码了,故加入下面这个逻辑。
在Spring4中在multipartCharset为空时,也不会自动添加charset,故没有此问题。
而根本原因是微信的服务器兼容性太差了,header中的charset是有http标准规定的,竟然不兼容!
|
org.springframework.http.HttpHeaders |
getHeaders() |
org.springframework.http.HttpMethod |
getMethod() |
String |
getMethodValue()
同样是兼容SB2.0, Spring5才加入的这个方法
不写Override,写了在4.x版本会报错,注意递归调用
|
URI |
getURI() |
public WxApiHttpRequest(org.springframework.http.client.ClientHttpRequest delegate)
public org.springframework.http.HttpMethod getMethod()
getMethod in interface org.springframework.http.HttpRequestpublic String getMethodValue()
getMethodValue in interface org.springframework.http.HttpRequestpublic URI getURI()
getURI in interface org.springframework.http.HttpRequestpublic org.springframework.http.client.ClientHttpResponse execute()
throws IOException
execute in interface org.springframework.http.client.ClientHttpRequestIOExceptionpublic OutputStream getBody() throws IOException
getBody in interface org.springframework.http.HttpOutputMessageIOExceptionpublic org.springframework.http.HttpHeaders getHeaders()
getHeaders in interface org.springframework.http.HttpMessageCopyright © 2018 Guangshan Technology, Inc.. All rights reserved.