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解码
  }

 

posted on 2018-05-22 14:39  唯忆学长  阅读(2815)  评论(0编辑  收藏  举报