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: nil returned for status code 4XX-5XX #58

Merged
Merged
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
14 changes: 7 additions & 7 deletions https/callBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (cb *defaultCallBuilder) Call() (*HttpContext, error) {
context := pipeline(request)

if cb.clientError != nil {
return nil, cb.clientError
err = cb.clientError
}

return &context, err
Expand Down Expand Up @@ -566,7 +566,7 @@ func (cb *defaultCallBuilder) CallAsJson() (*json.Decoder, *http.Response, error
cb.InterceptRequest(f)
result, err := cb.Call()
if err != nil {
return nil, nil, err
return nil, result.Response, err
}

if result.Response != nil {
Expand All @@ -576,7 +576,7 @@ func (cb *defaultCallBuilder) CallAsJson() (*json.Decoder, *http.Response, error

return json.NewDecoder(result.Response.Body), result.Response, err
}
return nil, nil, err
return nil, result.Response, err
}

// CallAsText executes the API call and returns the response body as a string and the HTTP response.
Expand All @@ -585,7 +585,7 @@ func (cb *defaultCallBuilder) CallAsJson() (*json.Decoder, *http.Response, error
func (cb *defaultCallBuilder) CallAsText() (string, *http.Response, error) {
result, err := cb.Call()
if err != nil {
return "", nil, err
return "", result.Response, err
}
if result.Response != nil {
if result.Response.Body == http.NoBody {
Expand All @@ -599,15 +599,15 @@ func (cb *defaultCallBuilder) CallAsText() (string, *http.Response, error) {

return string(body), result.Response, err
}
return "", nil, err
return "", result.Response, err
}

// CallAsStream executes the API call and returns the response body as a byte array and the HTTP response.
// It calls the Call method to make the API call and reads the response body as a byte array.
func (cb *defaultCallBuilder) CallAsStream() ([]byte, *http.Response, error) {
result, err := cb.Call()
if err != nil {
return nil, nil, err
return nil, result.Response, err
}

if result.Response != nil {
Expand All @@ -622,7 +622,7 @@ func (cb *defaultCallBuilder) CallAsStream() ([]byte, *http.Response, error) {

return bytes, result.Response, err
}
return nil, nil, err
return nil, result.Response, err
}

// addRetryInterceptor adds a retry interceptor to the call builder. This interceptor will handle retrying the API call
Expand Down
Loading