code: private byte[] readResponse(URLConnection connection) throws RpcException {
          byte[] resBytes;
          InputStream in = null;
          HttpURLConnection httpconnection = (HttpURLConnection) connection;
          try {
              if (httpconnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                  in = httpconnection.getInputStream();
              } else {
                  if (httpconnection.getContentType()
                          .equals(serializeHandler.getProtocol().getName())
                          && httpconnection.getErrorStream() != null) {
                      in = httpconnection.getErrorStream();
                  } else {
                      in = httpconnection.getInputStream();
                  }
              }
              int len = httpconnection.getContentLength();
              if (len <= 0) {
                  throw new RpcException("Response data length should not be zero");
              }
              resBytes = ByteUtil.readStream(in, len);
              if (LOG.isDebugEnabled()) {
                  LOG.debug("Read " + resBytes.length + " bytes response done");
              }
          } catch (IOException e) {
              throw new RpcException("Rpc read response from server has IO problems - "
                      + e.getMessage(), e);
          } finally {
              if (in != null) {
                  try {
                      in.close();
                  } catch (IOException e) {
                      LOG.error("Close read response connection error");
                  }
              }
          }
          return resBytes;
      }
docs: 读服务端返回数据
  
  @param connection
  @return 字节码
  @throws RpcException