Skip to content

Commit

Permalink
prepare release v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
KenChoi authored and KenChoi committed Jan 5, 2017
2 parents 253b46c + d20e591 commit ac8ed7f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testSendPushWithCallback() {
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jiguang-common</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<url>https://github.com/jpush/jiguang-java-client-common</url>
<connection>scm:git:git@github.com:jpush/jiguang-java-client-common.git</connection>
<developerConnection>scm:git:git@github.com:jpush/jiguang-java-client-common.git</developerConnection>
<tag>v1.0.1</tag>
<tag>v1.0.2</tag>
</scm>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cn.jiguang.common.connection;

import cn.jiguang.common.resp.APIRequestException;
import cn.jiguang.common.resp.ResponseWrapper;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.*;
Expand All @@ -11,6 +13,7 @@
import java.util.concurrent.CountDownLatch;


@ChannelHandler.Sharable
public class HttpResponseHandler extends SimpleChannelInboundHandler<HttpObject> {

private static final Logger LOG = LoggerFactory.getLogger(HttpResponseHandler.class);
Expand Down Expand Up @@ -41,15 +44,56 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Ex
String responseContent = content.content().toString(CharsetUtil.UTF_8);
_wrapper.responseCode = status;
_wrapper.responseContent = responseContent;
LOG.info("Got Response code: " + status + " content: " + responseContent);
System.err.println("Got Response code: " + status + " content: " + responseContent);
System.err.flush();
if (null != _callback) {
_callback.onSucceed(_wrapper);
if (status >= 200 && status < 300) {
LOG.debug("Succeed to get response OK - responseCode:" + status);
LOG.debug("Response Content - " + responseContent);

} else if (status >= 300 && status < 400) {
LOG.warn("Normal response but unexpected - responseCode:" + status + ", responseContent:" + responseContent);

} else {
LOG.warn("Got error response - responseCode:" + status + ", responseContent:" + responseContent);

switch (status) {
case 400:
LOG.error("Your request params is invalid. Please check them according to error message.");
_wrapper.setErrorObject();
break;
case 401:
LOG.error("Authentication failed! Please check authentication params according to docs.");
_wrapper.setErrorObject();
break;
case 403:
LOG.error("Request is forbidden! Maybe your appkey is listed in blacklist or your params is invalid.");
_wrapper.setErrorObject();
break;
case 404:
LOG.error("Request page is not found! Maybe your params is invalid.");
_wrapper.setErrorObject();
break;
case 410:
LOG.error("Request resource is no longer in service. Please according to notice on official website.");
_wrapper.setErrorObject();
case 429:
LOG.error("Too many requests! Please review your appkey's request quota.");
_wrapper.setErrorObject();
break;
case 500:
case 502:
case 503:
case 504:
LOG.error("Seems encountered server error. Maybe JPush is in maintenance? Please retry later.");
break;
default:
LOG.error("Unexpected response.");
}
}
if (null != _latch) {
_latch.countDown();
}
if (null != _callback) {
_callback.onSucceed(_wrapper);
}
}
}
}
Expand Down

0 comments on commit ac8ed7f

Please sign in to comment.