Skip to content

Commit 52bb01f

Browse files
fix: don't try to deserialize as json when ResponseBodyInto is []byte
1 parent 8d9d6fb commit 52bb01f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/requestconfig/requestconfig.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,15 +539,15 @@ func (cfg *RequestConfig) Execute() (err error) {
539539
return nil
540540
}
541541

542-
// If the response happens to be a byte array, deserialize the body as-is.
543542
switch dst := cfg.ResponseBodyInto.(type) {
543+
// If the response happens to be a byte array, deserialize the body as-is.
544544
case *[]byte:
545545
*dst = contents
546-
}
547-
548-
err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto)
549-
if err != nil {
550-
return fmt.Errorf("error parsing response json: %w", err)
546+
default:
547+
err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto)
548+
if err != nil {
549+
return fmt.Errorf("error parsing response json: %w", err)
550+
}
551551
}
552552

553553
return nil

0 commit comments

Comments
 (0)