HttpClient { public HttpInvokeResult invokeSync(final String addr, final HttpRequest request, final long timeoutMillis) throws InterruptedException { final Channel channel = this.getAndCreateChannel(addr); if (channel != null && channel.isActive()) { return this.invokeSyncImpl(channel, request, timeoutMillis); } else { final HttpInvokeResult invokeResult = new HttpInvokeResult(); invokeResult.setRemoteAddress(addr); invokeResult.setRequestURI(request.getUri()); invokeResult.setRequestMethod(request.getMethod().name()); invokeResult.setCause(new RemotingConnectException(addr)); log.warn("invokeSync: connect exception, " + invokeResult + ", close the channel"); this.closeChannel(addr, channel); return invokeResult; } } HttpClient(); void start(); void shutdown(); static SocketAddress string2SocketAddress(final String addr); static String parseChannelRemoteAddr(final Channel channel); static void closeChannel(Channel channel); void closeChannel(final String addr, final Channel channel); void processResponseMsg(ChannelHandlerContext ctx, HttpResponse msg); HttpInvokeResult get(String addr, String uri, long timeoutMillis); HttpInvokeResult get(String addr, String uri, Collection<Pair<String, ?>> headers, long timeoutMillis); HttpInvokeResult post(String addr, String uri, Collection<Pair<String, ?>> parameters, long timeoutMillis); HttpInvokeResult post(String addr, String uri, Collection<Pair<String, ?>> headers,
			Collection<Pair<String, ?>> parameters, long timeoutMillis); HttpInvokeResult invokeSync(final String addr, final HttpRequest request, final long timeoutMillis); HttpInvokeResult invokeSyncImpl(final Channel channel, final HttpRequest request, final long timeoutMillis);  }
@Test public void testInvoke() throws Exception { final String host = "config.ixiaopu.com"; final int port = 54321; HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/config.co?group=XIANGQU&dataId=GLOBAL"); request.headers().set(HttpHeaders.Names.HOST, host); request.headers().set(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP); final HttpInvokeResult result = this.httpClient.invokeSync(host + ":" + port, request, 5000); System.out.println(result); }