Skip to content

Commit c6a69b4

Browse files
committed
Fix "Fix http proxy server"
1 parent 83ce0be commit c6a69b4

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

protocol/http/handshake.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ func HandleConnection(ctx context.Context, conn net.Conn, reader *std_bufio.Read
2828
return E.Cause(err, "read http request")
2929
}
3030

31-
if hostStr := request.Header.Get("Host"); hostStr != "" {
32-
request.Host = hostStr
33-
request.URL.Host = hostStr
34-
}
35-
3631
if authenticator != nil {
3732
var authOk bool
3833
authorization := request.Header.Get("Proxy-Authorization")
@@ -89,6 +84,12 @@ func HandleConnection(ctx context.Context, conn net.Conn, reader *std_bufio.Read
8984
removeHopByHopHeaders(request.Header)
9085
removeExtraHTTPHostPort(request)
9186

87+
if hostStr := request.Header.Get("Host"); hostStr != "" {
88+
if hostStr != request.URL.Host {
89+
request.Host = hostStr
90+
}
91+
}
92+
9293
if request.URL.Scheme == "" || request.URL.Host == "" {
9394
return responseWith(request, http.StatusBadRequest).Write(conn)
9495
}

0 commit comments

Comments
 (0)