![JAR search and dependency download from the Maven repository](/logo.png)
com.mxixm.fastboot.weixin.controller.invoker.common.WxHttpInputMessageConverter Maven / Gradle / Ivy
The newest version!
package com.mxixm.fastboot.weixin.controller.invoker.common;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.converter.AbstractHttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.util.StreamUtils;
import java.io.IOException;
/**
* FastBootWeixin WxHttpInputMessageConverter
*
* @author Guangshan
* @summary FastBootWeixin WxHttpInputMessageConverter
* @Copyright (c) 2017, Guangshan Group All Rights Reserved
* @since 2017/8/13 10:53
*/
public class WxHttpInputMessageConverter extends AbstractHttpMessageConverter {
public WxHttpInputMessageConverter() {
super(MediaType.APPLICATION_OCTET_STREAM, MediaType.ALL);
}
@Override
protected boolean supports(Class> clazz) {
return HttpInputMessage.class.isAssignableFrom(clazz);
}
@Override
protected HttpInputMessage readInternal(Class extends HttpInputMessage> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
// 为何不直接返回inputMessage?因为在请求结束后,原始的inputMessage会被系统关闭,所以做了一层包装
return new WxBufferingInputMessageWrapper(inputMessage).init();
}
@Override
protected void writeInternal(HttpInputMessage httpInputMessage, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
StreamUtils.copy(httpInputMessage.getBody(), outputMessage.getBody());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy