Skip to content

Commit

Permalink
Add DoNotClearSuperAgent flag
Browse files Browse the repository at this point in the history
  • Loading branch information
roylou committed Apr 25, 2017
1 parent 5ba0c85 commit f96b4cd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gorequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type SuperAgent struct {
Attempt int
Enable bool
}
DoNotClearSuperAgent bool
}

var DisableTransportSwap = false
Expand Down Expand Up @@ -125,13 +126,22 @@ func (s *SuperAgent) SetCurlCommand(enable bool) *SuperAgent {
return s
}

// Enable the DoNotClear mode for not clearing super agent and reuse for the next request
func (s *SuperAgent) SetDoNotClearSuperAgent(enable bool) *SuperAgent {
s.DoNotClearSuperAgent = enable
return s
}

func (s *SuperAgent) SetLogger(logger Logger) *SuperAgent {
s.logger = logger
return s
}

// Clear SuperAgent data for another new request.
func (s *SuperAgent) ClearSuperAgent() {
if s.DoNotClearSuperAgent {
return
}
s.Url = ""
s.Method = ""
s.Header = make(map[string]string)
Expand Down

0 comments on commit f96b4cd

Please sign in to comment.