|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"golang.org/x/net/http2"
|
|
"crypto/tls"
|
|
)
|
|
|
|
func main() {
|
|
// force HTTP 2.0
|
|
tr := &http2.Transport{
|
|
TLSClientConfig: &tls.Config{InsecureSkipVerify : true},
|
|
}
|
|
client := &http.Client{Transport: tr}
|
|
|
|
// FIRST REQUEST: works, because of the trailing /
|
|
resp, err := client.Get("https://127.0.0.2/test/")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
fmt.Println("Response status:", resp.Status)
|
|
|
|
// SECOND REQUEST: warning because of the redirect
|
|
resp, err = client.Get("https://127.0.0.2/test")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
fmt.Println("Response status:", resp.Status)
|
|
}
|