Created
December 11, 2014 08:17
-
-
Save mcqueenorama/6f16870aa156675e64ae to your computer and use it in GitHub Desktop.
host precedence in url.URL.host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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