Skip to content

Instantly share code, notes, and snippets.

@mcqueenorama
Created December 11, 2014 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcqueenorama/6f16870aa156675e64ae to your computer and use it in GitHub Desktop.
Save mcqueenorama/6f16870aa156675e64ae to your computer and use it in GitHub Desktop.
host precedence in url.URL.host
// had to allocate this or the SetBasicAuth below causes a panic
headers := make(map[string][]string)
hostPort := fmt.Sprintf("%s:%d", hostname, port)
fmt.Fprintf(os.Stderr, "adding hostPort:%s:%d:path:%s:\n", hostname, port, path)
req := &http.Request{
Method: "HEAD",
// Host: hostPort, // takes precendence over URL.Host
URL: &url.URL{
Host: hostPort,
Scheme: "http",
Opaque: path,
},
Header: headers,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment