netty 发送 http请求

netty发送http请求,需要对请求和响应做编码处理

 

protected void initChannel(SocketChannel socketChannel) throws Exception {
                            socketChannel.pipeline().addLast(new HttpRequestEncoder());//对发送的httpRequest进行编码
                            socketChannel.pipeline().addLast(new HttpResponseDecoder());//对返回的httpresopnse解码
                            // socketChannel.pipeline().addLast(new HttpClientCodec());//即对发送的httpRequest进行编码,也对返回的httpresopnse解码
  }

 

转载于:https://www.cnblogs.com/chenhao0302/p/9071957.html

你可能感兴趣的:(netty 发送 http请求)