good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 1f07294c authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Rename ClientOptions Header to HTTPHeader

parent 27ec18a7
No related branches found
No related tags found
No related merge requests found
......@@ -22,9 +22,8 @@ type DialOptions struct {
// http.Transport does this correctly.
HTTPClient *http.Client
// Header specifies the HTTP headers included in the handshake request.
// TODO rename to HTTPHeader
Header http.Header
// HTTPHeader specifies the HTTP headers included in the handshake request.
HTTPHeader http.Header
// Subprotocols lists the subprotocols to negotiate with the server.
Subprotocols []string
......@@ -48,8 +47,8 @@ func dial(ctx context.Context, u string, opts DialOptions) (_ *Conn, _ *http.Res
if opts.HTTPClient == nil {
opts.HTTPClient = http.DefaultClient
}
if opts.Header == nil {
opts.Header = http.Header{}
if opts.HTTPHeader == nil {
opts.HTTPHeader = http.Header{}
}
parsedURL, err := url.Parse(u)
......@@ -68,7 +67,7 @@ func dial(ctx context.Context, u string, opts DialOptions) (_ *Conn, _ *http.Res
req, _ := http.NewRequest("GET", parsedURL.String(), nil)
req = req.WithContext(ctx)
req.Header = opts.Header
req.Header = opts.HTTPHeader
req.Header.Set("Connection", "Upgrade")
req.Header.Set("Upgrade", "websocket")
req.Header.Set("Sec-WebSocket-Version", "13")
......
......@@ -149,7 +149,7 @@ func TestHandshake(t *testing.T) {
h := http.Header{}
h.Set("Origin", "http://unauthorized.com")
c, _, err := websocket.Dial(ctx, u, websocket.DialOptions{
Header: h,
HTTPHeader: h,
})
if err == nil {
c.Close(websocket.StatusInternalError, "")
......@@ -172,7 +172,7 @@ func TestHandshake(t *testing.T) {
h := http.Header{}
h.Set("Origin", u)
c, _, err := websocket.Dial(ctx, u, websocket.DialOptions{
Header: h,
HTTPHeader: h,
})
if err != nil {
return err
......@@ -197,7 +197,7 @@ func TestHandshake(t *testing.T) {
h := http.Header{}
h.Set("Origin", "https://example.com")
c, _, err := websocket.Dial(ctx, u, websocket.DialOptions{
Header: h,
HTTPHeader: h,
})
if err != nil {
return err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment