Browse Source

fix: unexpected path in httpugprade (#2773)

ghosx 2 years ago
parent
commit
57d712a4d4
2 changed files with 13 additions and 1 deletions
  1. 12 0
      transport/internet/httpupgrade/config.go
  2. 1 1
      transport/internet/httpupgrade/dialer.go

+ 12 - 0
transport/internet/httpupgrade/config.go

@@ -0,0 +1,12 @@
+package httpupgrade
+
+func (c *Config) GetNormalizedPath() string {
+	path := c.Path
+	if path == "" {
+		return "/"
+	}
+	if path[0] != '/' {
+		return "/" + path
+	}
+	return path
+}

+ 1 - 1
transport/internet/httpupgrade/dialer.go

@@ -20,7 +20,7 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings *
 	if err != nil {
 		return nil, newError("failed to dial request to ", dest).Base(err)
 	}
-	req, err := http.NewRequest("GET", "/"+transportConfiguration.Path, nil)
+	req, err := http.NewRequest("GET", transportConfiguration.GetNormalizedPath(), nil)
 	if err != nil {
 		return nil, err
 	}