To make an HTTP connect request in Go, you can use the built-in net/http
package. Here is an example:
main.go600 chars36 lines
In this example, we create an HTTP client and a request object with the http.NewRequest
function. We set the request method to "CONNECT"
and the URL to "https://www.google.com:443"
. Then we execute the request with client.Do(req)
and read the response body using the ioutil.ReadAll(resp.Body)
function. Finally, we print the response as a string with fmt.Println(string(body))
.
gistlibby LogSnag