Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,25 @@ func (r *Request) BodyBytes() ([]byte, error) {

// Update request URL with new changes of parameters if any
func (r *Request) Update() {
// Make a copy of the URL to avoid data races
r.URL = r.URL.Clone()
r.URL.Update()
r.Request.URL = r.URL.URL
updateScheme(r.URL.URL)
}

// SetURL updates request url (i.e http.Request.URL) with given url
func (r *Request) SetURL(u *urlutil.URL) {
r.URL = u
// Make a copy of the URL to avoid data races
r.URL = u.Clone()
r.Request.URL = u.URL
r.Update()
}

// Clones and returns new Request
func (r *Request) Clone(ctx context.Context) *Request {
r.Update()
ux := r.URL.Clone()
ux := r.URL
req := r.Request.Clone(ctx)
req.URL = ux.URL
ux.Update()
Expand Down
Loading