HttpClient { public HttpInvokeResult get(String addr, String uri, long timeoutMillis) { return get(addr, uri, null, timeoutMillis); } 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 testGet() throws Exception { final String host = "config.ixiaopu.com"; final int port = 54321; Collection<Pair<String, ?>> headers = new ArrayList<Pair<String, ?>>(); headers.add(Pair.of(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP)); final HttpInvokeResult result = this.httpClient.get(host + ":" + port, "/config.co?group=XIANGQU&dataId=GLOBAL", headers, 5000); System.out.println(result); final String content = result.getResponseBodyAsString(); System.out.println(content); final byte[] data = result.getResponseBody(); System.out.println(new String(data, Constants.ENCODE)); System.out.println(result.getHeader(Constants.CONTENT_MD5)); System.out.println(); }
@Test public void testGet2() throws Exception { System.out.println(this.httpClient.get("config.xiangqutest.com:12345", "/ServerNodes", 5000)); }