Skip to content

Commit 1f07294

Browse files
committed
Rename ClientOptions Header to HTTPHeader
1 parent 27ec18a commit 1f07294

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

dial.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ type DialOptions struct {
2222
// http.Transport does this correctly.
2323
HTTPClient *http.Client
2424

25-
// Header specifies the HTTP headers included in the handshake request.
26-
// TODO rename to HTTPHeader
27-
Header http.Header
25+
// HTTPHeader specifies the HTTP headers included in the handshake request.
26+
HTTPHeader http.Header
2827

2928
// Subprotocols lists the subprotocols to negotiate with the server.
3029
Subprotocols []string
@@ -48,8 +47,8 @@ func dial(ctx context.Context, u string, opts DialOptions) (_ *Conn, _ *http.Res
4847
if opts.HTTPClient == nil {
4948
opts.HTTPClient = http.DefaultClient
5049
}
51-
if opts.Header == nil {
52-
opts.Header = http.Header{}
50+
if opts.HTTPHeader == nil {
51+
opts.HTTPHeader = http.Header{}
5352
}
5453

5554
parsedURL, err := url.Parse(u)
@@ -68,7 +67,7 @@ func dial(ctx context.Context, u string, opts DialOptions) (_ *Conn, _ *http.Res
6867

6968
req, _ := http.NewRequest("GET", parsedURL.String(), nil)
7069
req = req.WithContext(ctx)
71-
req.Header = opts.Header
70+
req.Header = opts.HTTPHeader
7271
req.Header.Set("Connection", "Upgrade")
7372
req.Header.Set("Upgrade", "websocket")
7473
req.Header.Set("Sec-WebSocket-Version", "13")

websocket_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func TestHandshake(t *testing.T) {
149149
h := http.Header{}
150150
h.Set("Origin", "http://unauthorized.com")
151151
c, _, err := websocket.Dial(ctx, u, websocket.DialOptions{
152-
Header: h,
152+
HTTPHeader: h,
153153
})
154154
if err == nil {
155155
c.Close(websocket.StatusInternalError, "")
@@ -172,7 +172,7 @@ func TestHandshake(t *testing.T) {
172172
h := http.Header{}
173173
h.Set("Origin", u)
174174
c, _, err := websocket.Dial(ctx, u, websocket.DialOptions{
175-
Header: h,
175+
HTTPHeader: h,
176176
})
177177
if err != nil {
178178
return err
@@ -197,7 +197,7 @@ func TestHandshake(t *testing.T) {
197197
h := http.Header{}
198198
h.Set("Origin", "https://example.com")
199199
c, _, err := websocket.Dial(ctx, u, websocket.DialOptions{
200-
Header: h,
200+
HTTPHeader: h,
201201
})
202202
if err != nil {
203203
return err

0 commit comments

Comments
 (0)