HttpClientResponse response;
if (resp.statusCode() == 200) {
// connect successful force the modification of the ChannelPipeline
// beside this also pause the socket for now so the user has a chance to register its dataHandler
// after received the NetSocket
NetSocket socket = resp.netSocket();
socket.pause();
response = new HttpClientResponse() {
private boolean resumed;
@Override
public int statusCode() {
return resp.statusCode();
}
@Override
public String statusMessage() {
return resp.statusMessage();
}
@Override
public MultiMap headers() {
return resp.headers();
}
@Override
public MultiMap trailers() {
return resp.trailers();
}
@Override
public List<String> cookies() {
return resp.cookies();
}
@Override
public HttpClientResponse bodyHandler(Handler<Buffer> bodyHandler) {
resp.bodyHandler(bodyHandler);
return this;
}
@Override
public synchronized NetSocket netSocket() {
if (!resumed) {
resumed = true;
vertx.getContext().runOnContext((v) -> socket.resume()); // resume the socket now as the user had the chance to register a dataHandler
}
return socket;
}
@Override