Created
December 19, 2017 01:03
-
-
Save partkyle/ea595328e3596a0fbd2aa7a0536a98c6 to your computer and use it in GitHub Desktop.
Send a request to an IP address but use a specific hostname
This file contains hidden or 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
package main | |
import ( | |
"crypto/tls" | |
"log" | |
"net/http" | |
) | |
func main() { | |
client := &http.Client{ | |
Transport: &http.Transport{ | |
TLSClientConfig: &tls.Config{ | |
ServerName: "sendgrid.com", | |
}, | |
}, | |
} | |
req, err := http.NewRequest("GET", "https://167.89.118.65", nil) | |
if err != nil { | |
log.Fatal(err) | |
} | |
resp, err := client.Do(req) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer resp.Body.Close() | |
log.Printf("statusCode=%d", resp.StatusCode) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment