(t *testing.T)
| 1099 | } |
| 1100 | } |
| 1101 | func TestNextProtos(t *testing.T) { |
| 1102 | ts := httptest.NewUnstartedServer( |
| 1103 | http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}), |
| 1104 | ) |
| 1105 | ts.EnableHTTP2 = true |
| 1106 | ts.StartTLS() |
| 1107 | defer ts.Close() |
| 1108 | |
| 1109 | d := Dialer{ |
| 1110 | TLSClientConfig: ts.Client().Transport.(*http.Transport).TLSClientConfig, |
| 1111 | } |
| 1112 | |
| 1113 | r, err := ts.Client().Get(ts.URL) |
| 1114 | if err != nil { |
| 1115 | t.Fatalf("Get: %v", err) |
| 1116 | } |
| 1117 | r.Body.Close() |
| 1118 | |
| 1119 | // Asserts that Dialer.TLSClientConfig.NextProtos contains "h2" |
| 1120 | // after the Client.Get call from net/http above. |
| 1121 | var containsHTTP2 bool = false |
| 1122 | for _, proto := range d.TLSClientConfig.NextProtos { |
| 1123 | if proto == "h2" { |
| 1124 | containsHTTP2 = true |
| 1125 | } |
| 1126 | } |
| 1127 | if !containsHTTP2 { |
| 1128 | t.Fatalf("Dialer.TLSClientConfig.NextProtos does not contain \"h2\"") |
| 1129 | } |
| 1130 | |
| 1131 | _, _, err = d.Dial(makeWsProto(ts.URL), nil) |
| 1132 | if err == nil { |
| 1133 | t.Fatalf("Dial succeeded, expect fail ") |
| 1134 | } |
| 1135 | } |
nothing calls this directly
no test coverage detected