Skip to content

Commit

Permalink
fix: should drain resp.Body if not readAll or dump
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHaoJun authored and tiaguinho committed Jul 29, 2022
1 parent 4531510 commit 5bd4125
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions soap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/xml"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -261,6 +262,12 @@ func (p *process) doRequest(url string) ([]byte, error) {
}

if resp.StatusCode < 200 || resp.StatusCode >= 400 {
if !(p.Client.config != nil && p.Client.config.Dump) {
_, err := io.Copy(ioutil.Discard, resp.Body)
if err != nil {
return nil, err
}
}
return nil, errors.New("unexpected status code: " + resp.Status)
}

Expand Down

0 comments on commit 5bd4125

Please sign in to comment.