Skip to content

Commit 01148bb

Browse files
authored
Merge pull request #51 from wjdp/fix/49
Update TLS conf to actually disable H2
2 parents 01868ff + 9b03043 commit 01148bb

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

htmltest/check-link_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ func TestAnchorExternalHTTPSInvalid(t *testing.T) {
128128
tExpectIssueCount(t, hT, 6)
129129
}
130130

131+
func TestAnchorExternalHTTPSBadH2(t *testing.T) {
132+
// should connect to servers with bad http/2 support
133+
// See issue #49
134+
tSkipShortExternal(t)
135+
hT := tTestFile("fixtures/links/https-valid-h2.html")
136+
tExpectIssueCount(t, hT, 0)
137+
}
138+
131139
func TestAnchorExternalMissingProtocolValid(t *testing.T) {
132140
// works for valid links missing the protocol
133141
tSkipShortExternal(t)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
3+
<body>
4+
<a href="https://f5.com/">F5, the people who make BIG/IP, which can't do HTTP/2 very well</a>
5+
<a href="https://www.southampton.ac.uk/">Southampton Uni, who use BIG/IP and therefore cannot do HTTP/2 very well</a>
6+
<a href="https://www.southampton.ac.uk/">Southampton Uni, who use BIG/IP and therefore cannot do HTTP/2 very well</a>
7+
8+
<a href="https://www.linkedin.com/">LinkedIn does not seem to support APLN.</a>
9+
</body>
10+
11+
</html>

htmltest/htmltest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"path"
1212
"sync"
1313
"time"
14+
"crypto/tls"
1415
)
1516

1617
// HTMLTest struct, A html testing session, user options are passed in and
@@ -42,7 +43,12 @@ func Test(optsUser map[string]interface{}) *HTMLTest {
4243
(hT.opts.LogSort == "seq"))
4344

4445
transport := &http.Transport{
45-
TLSNextProto: nil, // Disable HTTP/2, "write on closed buffer" errors
46+
// Disable HTTP/2, this is required due to a number of edge cases where http negotiates H2, but something goes
47+
// wrong when actually using it. Downgrading to H1 when this issue is hit is not yet supported so we use the
48+
// following to disable H2 support:
49+
// > Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto ... to a non-nil, empty map.
50+
// See issue #49
51+
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
4652
}
4753
hT.httpClient = &http.Client{
4854
// Durations are in nanoseconds

0 commit comments

Comments
 (0)