Skip to content

Commit a4f27c4

Browse files
committed
net/http: update bundled copied of x/net/http2 to git rev 961116aee
Update net/http's copy of http2 (sync as of x/net git rev 961116aee, aka https://golang.org/cl/18266) Also adds some CONNECT tests for #13717 (mostly a copy of http2's version of test, but in the main repo it also tests that http1 behaves the same) Fixes #13668 Fixes #13717 Change-Id: I7db93fe0b7c42bd17a43ef32953f2d20620dd3ea Reviewed-on: https://go-review.googlesource.com/18269 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent ed52e55 commit a4f27c4

File tree

2 files changed

+196
-62
lines changed

2 files changed

+196
-62
lines changed

src/net/http/clientserver_test.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"log"
1717
. "net/http"
1818
"net/http/httptest"
19+
"net/url"
1920
"os"
2021
"reflect"
2122
"sort"
@@ -675,3 +676,61 @@ func testConcurrentReadWriteReqBody(t *testing.T, h2 bool) {
675676
t.Errorf("read %q; want %q", data, resBody)
676677
}
677678
}
679+
680+
func TestConnectRequest_h1(t *testing.T) { testConnectRequest(t, h1Mode) }
681+
func TestConnectRequest_h2(t *testing.T) { testConnectRequest(t, h2Mode) }
682+
func testConnectRequest(t *testing.T, h2 bool) {
683+
defer afterTest(t)
684+
gotc := make(chan *Request, 1)
685+
cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {
686+
gotc <- r
687+
}))
688+
defer cst.close()
689+
690+
u, err := url.Parse(cst.ts.URL)
691+
if err != nil {
692+
t.Fatal(err)
693+
}
694+
695+
tests := []struct {
696+
req *Request
697+
want string
698+
}{
699+
{
700+
req: &Request{
701+
Method: "CONNECT",
702+
Header: Header{},
703+
URL: u,
704+
},
705+
want: u.Host,
706+
},
707+
{
708+
req: &Request{
709+
Method: "CONNECT",
710+
Header: Header{},
711+
URL: u,
712+
Host: "example.com:123",
713+
},
714+
want: "example.com:123",
715+
},
716+
}
717+
718+
for i, tt := range tests {
719+
res, err := cst.c.Do(tt.req)
720+
if err != nil {
721+
t.Errorf("%d. RoundTrip = %v", i, err)
722+
continue
723+
}
724+
res.Body.Close()
725+
req := <-gotc
726+
if req.Method != "CONNECT" {
727+
t.Errorf("method = %q; want CONNECT", req.Method)
728+
}
729+
if req.Host != tt.want {
730+
t.Errorf("Host = %q; want %q", req.Host, tt.want)
731+
}
732+
if req.URL.Host != tt.want {
733+
t.Errorf("URL.Host = %q; want %q", req.URL.Host, tt.want)
734+
}
735+
}
736+
}

0 commit comments

Comments
 (0)