|
|
@@ -120,11 +120,11 @@ Start:
|
|
|
}
|
|
|
|
|
|
defaultPort := net.Port(80)
|
|
|
- if strings.ToLower(request.URL.Scheme) == "https" {
|
|
|
+ if strings.EqualFold(request.URL.Scheme, "https") {
|
|
|
defaultPort = net.Port(443)
|
|
|
}
|
|
|
host := request.Host
|
|
|
- if len(host) == 0 {
|
|
|
+ if host == "" {
|
|
|
host = request.URL.Host
|
|
|
}
|
|
|
dest, err := http_proto.ParseHost(host, defaultPort)
|
|
|
@@ -137,7 +137,7 @@ Start:
|
|
|
Status: log.AccessAccepted,
|
|
|
})
|
|
|
|
|
|
- if strings.ToUpper(request.Method) == "CONNECT" {
|
|
|
+ if strings.EqualFold(request.Method, "CONNECT") {
|
|
|
return s.handleConnect(ctx, request, reader, conn, dest, dispatcher)
|
|
|
}
|
|
|
|
|
|
@@ -211,7 +211,7 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade
|
|
|
var errWaitAnother = newError("keep alive")
|
|
|
|
|
|
func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, writer io.Writer, dest net.Destination, dispatcher routing.Dispatcher) error {
|
|
|
- if !s.config.AllowTransparent && len(request.URL.Host) <= 0 {
|
|
|
+ if !s.config.AllowTransparent && request.URL.Host == "" {
|
|
|
// RFC 2068 (HTTP/1.1) requires URL to be absolute URL in HTTP proxy.
|
|
|
response := &http.Response{
|
|
|
Status: "Bad Request",
|
|
|
@@ -235,7 +235,7 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, wri
|
|
|
http_proto.RemoveHopByHopHeaders(request.Header)
|
|
|
|
|
|
// Prevent UA from being set to golang's default ones
|
|
|
- if len(request.Header.Get("User-Agent")) == 0 {
|
|
|
+ if request.Header.Get("User-Agent") == "" {
|
|
|
request.Header.Set("User-Agent", "")
|
|
|
}
|
|
|
|