Skip to content

Commit

Permalink
fix: try to fix EOF error
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Oct 11, 2024
1 parent b279c61 commit dea7bc4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/requester/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net/http"
"net/url"
"time"

emperror "emperror.dev/errors"
)
Expand Down Expand Up @@ -64,6 +65,14 @@ func (requester *Requester) GetURL(path string, query ...string) url.URL {
return url
}

var httpClient = &http.Client{
Transport: &http.Transport{
MaxIdleConns: 10,
IdleConnTimeout: 30 * time.Second,
DisableCompression: true,
},
}

func (requester *Requester) Request(method string, url url.URL, body []byte, header http.Header) (resp *http.Response, respBody []byte, err error) {
if url.Scheme == "" {
url.Scheme = requester.GetSchema()
Expand All @@ -89,11 +98,7 @@ func (requester *Requester) Request(method string, url url.URL, body []byte, hea
if req.Header.Get("Accept") == "" {
req.Header.Set("Accept", "application/json")
}
req.Close = true

tr := http.DefaultTransport.(*http.Transport).Clone()
tr.TLSClientConfig.InsecureSkipVerify = true
httpClient := http.Client{Transport: tr}
resp, err = httpClient.Do(req)
if err != nil {
return nil, nil, emperror.Wrap(err, "failed to request API")
Expand Down

0 comments on commit dea7bc4

Please sign in to comment.