Skip to content

Commit

Permalink
Reafactor error check after review
Browse files Browse the repository at this point in the history
  • Loading branch information
becheran committed Mar 7, 2022
1 parent 5c93662 commit 3b1bcc7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,14 +1291,20 @@ func (resp *Response) ReadLimitBody(r *bufio.Reader, maxBodySize int) error {

if !resp.mustSkipBody() {
err = resp.ReadBody(r, maxBodySize)
if err != nil && !errors.Is(err, syscall.ECONNRESET) {
if err != nil {
if errors.Is(err, syscall.ECONNRESET) {
return nil
}
return err
}
}

if resp.Header.ContentLength() == -1 {
err = resp.Header.ReadTrailer(r)
if err != nil && err != io.EOF && !errors.Is(err, syscall.ECONNRESET) {
if err != nil && err != io.EOF {
if errors.Is(err, syscall.ECONNRESET) {
return nil
}
return err
}
}
Expand Down

0 comments on commit 3b1bcc7

Please sign in to comment.