Browse Source

HTTP transport: Use dest as Host if not set (#4038)

main
风扇滑翔翼 23 hours ago committed by GitHub
parent
commit
0a252ac15d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      transport/internet/http/config.go
  2. 9
      transport/internet/http/dialer.go

2
transport/internet/http/config.go

@ -8,7 +8,7 @@ import (
func (c *Config) getHosts() []string { func (c *Config) getHosts() []string {
if len(c.Host) == 0 { if len(c.Host) == 0 {
return []string{"www.example.com"} return []string{""}
} }
return c.Host return c.Host
} }

9
transport/internet/http/dialer.go

@ -215,9 +215,16 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
} }
} }
Host := httpSettings.getRandomHost()
if Host == "" && net.ParseAddress(dest.NetAddr()).Family().IsDomain() {
Host = dest.Address.String()
} else if Host == "" {
Host = "www.example.com"
}
request := &http.Request{ request := &http.Request{
Method: httpMethod, Method: httpMethod,
Host: httpSettings.getRandomHost(), Host: Host,
Body: breader, Body: breader,
URL: &url.URL{ URL: &url.URL{
Scheme: "https", Scheme: "https",

Loading…
Cancel
Save