Skip to content

Commit

Permalink
Merge pull request #16 from masterZSH/master
Browse files Browse the repository at this point in the history
Fix Manually passed `Cookie` header overrides `http.CookieJar` cookies
  • Loading branch information
tebruno99 authored Dec 13, 2022
2 parents 76ecc29 + c19c24a commit aa3e549
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,6 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
}
req = req.WithContext(ctx)

// Set the cookies present in the cookie jar of the dialer
if d.Jar != nil {
for _, cookie := range d.Jar.Cookies(u) {
req.AddCookie(cookie)
}
}

// Set the request headers using the capitalization for names and values in
// RFC examples. Although the capitalization shouldn't matter, there are
// servers that depend on it. The Header.Set method is not used because the
Expand Down Expand Up @@ -235,6 +228,13 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
}
}

// Set the cookies present in the cookie jar of the dialer
if d.Jar != nil {
for _, cookie := range d.Jar.Cookies(u) {
req.AddCookie(cookie)
}
}

if d.EnableCompression {
req.Header["Sec-WebSocket-Extensions"] = []string{"permessage-deflate; server_no_context_takeover; client_no_context_takeover"}
}
Expand Down

0 comments on commit aa3e549

Please sign in to comment.