httpclient bug fixed
This commit is contained in:
@@ -181,15 +181,25 @@ public class WeixinRequest implements HttpMessage {
|
||||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecoderResult decoderResult() {
|
||||
return decoderResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpVersion protocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WeixinRequest [headers=" + headers.entries() + ", method=" + method
|
||||
+ ", uri=" + uri + ", echoStr=" + echoStr + ", timeStamp="
|
||||
+ timeStamp + ", nonce=" + nonce + ", signature=" + signature
|
||||
+ ", msgSignature=" + msgSignature + ", encryptType="
|
||||
+ encryptType + ", originalContent=" + originalContent
|
||||
+ ", encryptContent=" + encryptContent + ", aesToken="
|
||||
+ aesToken + ", decoderResult=" + decoderResult
|
||||
return "WeixinRequest [headers=" + headers.entries() + ", method="
|
||||
+ method + ", uri=" + uri + ", echoStr=" + echoStr
|
||||
+ ", timeStamp=" + timeStamp + ", nonce=" + nonce
|
||||
+ ", signature=" + signature + ", msgSignature=" + msgSignature
|
||||
+ ", encryptType=" + encryptType + ", originalContent="
|
||||
+ originalContent + ", encryptContent=" + encryptContent
|
||||
+ ", aesToken=" + aesToken + ", decoderResult=" + decoderResult
|
||||
+ ", protocolVersion=" + protocolVersion + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ public class WeixinMessageDecoder extends
|
||||
protected void decode(ChannelHandlerContext ctx, FullHttpRequest req,
|
||||
List<Object> out) throws WeixinException {
|
||||
String messageContent = req.content().toString(ServerToolkits.UTF_8);
|
||||
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri(),
|
||||
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.uri(),
|
||||
true);
|
||||
HttpMethod method = req.getMethod();
|
||||
logger.info("decode request:{} use {} method invoking", req.getUri(),
|
||||
HttpMethod method = req.method();
|
||||
logger.info("decode request:{} use {} method invoking", req.uri(),
|
||||
method);
|
||||
Map<String, List<String>> parameters = queryDecoder.parameters();
|
||||
EncryptType encryptType = parameters.containsKey("encrypt_type") ? EncryptType
|
||||
@@ -104,11 +104,11 @@ public class WeixinMessageDecoder extends
|
||||
}
|
||||
logger.info("read original message {}", messageContent);
|
||||
WeixinRequest request = new WeixinRequest(req.headers(), method,
|
||||
req.getUri(), encryptType, echoStr, timeStamp, nonce,
|
||||
req.uri(), encryptType, echoStr, timeStamp, nonce,
|
||||
signature, msgSignature, messageContent, encryptContent,
|
||||
aesToken);
|
||||
request.setDecoderResult(req.getDecoderResult());
|
||||
request.setProtocolVersion(req.getProtocolVersion());
|
||||
request.setDecoderResult(req.decoderResult());
|
||||
request.setProtocolVersion(req.protocolVersion());
|
||||
out.add(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class WeixinRequestHandler extends
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
ctx.close();
|
||||
logger.error("catch the exception:", cause);
|
||||
logger.error(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-3
@@ -23,8 +23,7 @@ import com.foxinmy.weixin4j.util.AesToken;
|
||||
public class WeixinServerInitializer extends ChannelInitializer<SocketChannel> {
|
||||
|
||||
private final WeixinMessageDispatcher messageDispatcher;
|
||||
|
||||
private WeixinMessageDecoder messageDecoder;
|
||||
private final WeixinMessageDecoder messageDecoder;
|
||||
|
||||
public WeixinServerInitializer(Map<String, AesToken> aesTokenMap,
|
||||
WeixinMessageDispatcher messageDispatcher) {
|
||||
@@ -32,7 +31,7 @@ public class WeixinServerInitializer extends ChannelInitializer<SocketChannel> {
|
||||
this.messageDecoder = new WeixinMessageDecoder(aesTokenMap);
|
||||
}
|
||||
|
||||
public int addAesToken(final AesToken asetoken){
|
||||
public int addAesToken(final AesToken asetoken) {
|
||||
return messageDecoder.addAesToken(asetoken);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public final class WeixinServerBootstrap {
|
||||
*/
|
||||
private final Map<String, AesToken> aesTokenMap;
|
||||
|
||||
WeixinServerInitializer wechatInitializer;
|
||||
private WeixinServerInitializer wechatInitializer;
|
||||
|
||||
static {
|
||||
DEFAULT_BOSSTHREADS = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.foxinmy.weixin4j.util;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH;
|
||||
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
|
||||
import static io.netty.handler.codec.http.HttpHeaders.Names.DATE;
|
||||
import static io.netty.handler.codec.http.HttpHeaders.Names.USER_AGENT;
|
||||
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH;
|
||||
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE;
|
||||
import static io.netty.handler.codec.http.HttpHeaderNames.DATE;
|
||||
import static io.netty.handler.codec.http.HttpHeaderNames.USER_AGENT;
|
||||
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpResponse;
|
||||
|
||||
Reference in New Issue
Block a user