blob: b2af55a7b713778ac2fa23c17e67c04ff0ed6d23 [file] [log] [blame]
Brad Fitzpatrickfcb18db2015-02-02 15:41:30 +00001// Copyright 2015 The Go Authors.
2// See https://go.googlesource.com/go/+/master/CONTRIBUTORS
3// Licensed under the same terms as Go itself:
4// https://go.googlesource.com/go/+/master/LICENSE
5
6package http2
7
8import (
9 "flag"
10 "net/http"
11 "os"
12 "testing"
13)
14
Brad Fitzpatrick07ee6802015-02-03 12:57:45 +000015var (
16 extNet = flag.Bool("extnet", false, "do external network tests")
17 transportHost = flag.String("transporthost", "http2.golang.org", "hostname to use for TestTransport")
Brad Fitzpatrickd1a857d2015-02-08 16:49:28 -080018 insecure = flag.Bool("insecure", false, "insecure TLS dials")
Brad Fitzpatrick07ee6802015-02-03 12:57:45 +000019)
Brad Fitzpatrickfcb18db2015-02-02 15:41:30 +000020
21func TestTransport(t *testing.T) {
22 if !*extNet {
23 t.Skip("skipping external network test")
24 }
Brad Fitzpatrick07ee6802015-02-03 12:57:45 +000025 req, _ := http.NewRequest("GET", "https://"+*transportHost+"/", nil)
Brad Fitzpatrickd1a857d2015-02-08 16:49:28 -080026 rt := &Transport{
27 InsecureTLSDial: *insecure,
28 }
Brad Fitzpatrickfcb18db2015-02-02 15:41:30 +000029 res, err := rt.RoundTrip(req)
30 if err != nil {
31 t.Fatalf("%v", err)
32 }
33 res.Write(os.Stdout)
34}