message: Optimized http local code
diff: @@ -210,25 +210,38 @@ async fn server_dispatch(
  client_addr: SocketAddr,
  client: ShadowSocksClient,
  ) -> Result<Response<Body>, io::Error> {
  + // Parse URI
  + //
  + // Proxy request URI must contains a host
  + let host = match host_addr(req.uri()) {
  + None => {
  + error!("HTTP {} URI is not a valid address. URI: {}", req.method(), req.uri());
  +
  + let mut resp = Response::new(Body::from("URI must be a valid Address"));
  + *resp.status_mut() = StatusCode::BAD_REQUEST;
  +
  + return Ok(resp);
  + }
  + Some(h) => h,
  + };
  +
  if Method::CONNECT == req.method() {
  // Establish a TCP tunnel
  // https://tools.ietf.org/html/draft-luotonen-web-proxy-tunneling-01
  - match host_addr(req.uri()) {
  - Some(addr) => {
  - debug!("CONNECT {}", addr);
  + debug!("HTTP CONNECT {}", host);
  // Connect to Shadowsocks' remote
  //
  // FIXME: What STATUS should I return for connection error?
  let stream = super::connect_proxy_server(&*context, &*svr_cfg).await?;
  - let stream = super::proxy_server_handshake(stream, svr_cfg.clone(), &addr).await?;
  + let stream = super::proxy_server_handshake(stream, svr_cfg.clone(), &host).await?;
  debug!(
  "CONNECT relay connected {} <-> {} ({})",
  client_addr,
  svr_cfg.addr(),
  - addr
  + host
  );
  // Upgrade to a TCP tunnel
  @@ -243,17 +256,17 @@ async fn server_dispatch(
  "CONNECT tunnel upgrade success, {} <-> {} ({})",
  client_addr,
  svr_cfg.addr(),
  - addr
  + host
  );
  - establish_connect_tunnel(upgraded, stream, svr_cfg, client_addr, addr).await
  + establish_connect_tunnel(upgraded, stream, svr_cfg, client_addr, host).await
  }
  Err(e) => {
  error!(
  "Failed to upgrade TCP tunnel {} <-> {} ({}), error: {}",
  client_addr,
  svr_cfg.addr(),
  - addr,
  + host,
  e
  );
  }
  @@ -266,31 +279,9 @@ async fn server_dispatch(
  .unwrap();
  Ok(resp)
  - }
  - None => {
  - error!("HTTP CONNECT URI is not a valid address. URI: {}", req.uri());
  -
  - let mut resp = Response::new(Body::from("CONNECT URI must be a valid Address"));
  - *resp.status_mut() = StatusCode::BAD_REQUEST;
  -
  - Ok(resp)
  - }
  - }
  } else {
  let method = req.method().clone();
  - let host = match host_addr(req.uri()) {
  - None => {
  - error!("HTTP {} URI is not a valid address. URI: {}", method, req.uri());
  -
  - let mut resp = Response::new(Body::from("URI must be a valid Address"));
  - *resp.status_mut() = StatusCode::BAD_REQUEST;
  -
  - return Ok(resp);
  - }
  - Some(h) => h,
  - };
  -
  debug!("HTTP {} {}", method, host);
  let res = match client.request(req).await {
  