Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix file descriptor leak problem & enable keepalive by default #191

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions gorequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ func New() *SuperAgent {
CurlCommand: false,
logger: log.New(os.Stderr, "[gorequest]", log.LstdFlags),
}
// disable keep alives by default, see this issue https://github.com/parnurzeal/gorequest/issues/75
s.Transport.DisableKeepAlives = true
return s
}

Expand Down Expand Up @@ -1106,7 +1104,6 @@ func (s *SuperAgent) getResponseBytes() (Response, []byte, []error) {
s.Errors = append(s.Errors, err)
return nil, nil, s.Errors
}
defer resp.Body.Close()

// Log details of this response
if s.Debug {
Expand All @@ -1119,6 +1116,7 @@ func (s *SuperAgent) getResponseBytes() (Response, []byte, []error) {
}

body, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
// Reset resp.Body so it can be use again
resp.Body = ioutil.NopCloser(bytes.NewBuffer(body))

Expand Down