Skip to content

Commit

Permalink
Handle more case
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed May 2, 2016
1 parent 7498666 commit 7983fb1
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/main/java/io/vertx/core/http/impl/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.VertxException;
import io.vertx.core.http.ConnectionPoolTooBusyException;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpVersion;
Expand Down Expand Up @@ -285,27 +286,26 @@ protected void initChannel(Channel ch) throws Exception {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpResponse) {
if (status != null) {
// Handle this case
}
status = ((HttpResponse) msg).status();
}
if (msg instanceof LastHttpContent) {
pipeline.remove("codec");
pipeline.remove(this);
if (status == null) {
// Handle this case
}
int sc = status.code();
System.out.println("sc = " + sc);
if (sc == 200) {
pipeline.remove("codec");
pipeline.remove(this);
channelHandler.handle(Future.succeededFuture(ch));
throw new VertxException("");
} else {
channelHandler.handle(Future.failedFuture("Could not connect " + sc));
// Handle this case
int sc = status.code();
if (sc == 200) {
channelHandler.handle(Future.succeededFuture(ch));
} else {
throw new VertxException("Could not connect " + sc);
}
}
}
super.channelRead(ctx, msg);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
channelHandler.handle(Future.failedFuture(cause));
}
});
}
Expand Down

0 comments on commit 7983fb1

Please sign in to comment.