Compare commits

..

1 Commits

Author SHA1 Message Date
fda016d011 v1.5.11 2023-11-29 11:57:03 +03:00
3 changed files with 28 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
## Version 1.5.9 ## Version 1.5.11
### Bugfix ### Bugfix
- Refactored clients to fix the problems with retries - Fix unhandled error in do() method for client and legacy-client

View File

@@ -148,16 +148,17 @@ func (dc *DecortClient) do(req *http.Request) (*http.Response, error) {
// req = req.Clone(req.Context()) // req = req.Clone(req.Context())
req.Body = io.NopCloser(bytes.NewBuffer(buf)) req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := dc.client.Do(req) resp, err := dc.client.Do(req)
if err != nil || resp == nil {
// if err == nil {
if resp.StatusCode == 200 {
return resp, err return resp, err
} }
if resp.StatusCode == 200 {
return resp, nil
}
respBytes, _ := io.ReadAll(resp.Body) respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes) err = fmt.Errorf("%s", respBytes)
resp.Body.Close() resp.Body.Close()
// }
// }
return nil, fmt.Errorf("could not execute request: %w", err) return nil, fmt.Errorf("could not execute request: %w", err)
} }

View File

@@ -145,16 +145,17 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
// req = req.Clone(req.Context()) // req = req.Clone(req.Context())
req.Body = io.NopCloser(bytes.NewBuffer(buf)) req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := ldc.client.Do(req) resp, err := ldc.client.Do(req)
if err != nil || resp == nil {
// if err == nil {
if resp.StatusCode == 200 {
return resp, err return resp, err
} }
if resp.StatusCode == 200 {
return resp, nil
}
respBytes, _ := io.ReadAll(resp.Body) respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes) err = fmt.Errorf("%s", respBytes)
resp.Body.Close() resp.Body.Close()
// }
// }
return nil, fmt.Errorf("could not execute request: %w", err) return nil, fmt.Errorf("could not execute request: %w", err)
} }