Skip to content

Commit 74ad0f8

Browse files
fix: don't try to deserialize as json when ResponseBodyInto is []byte
1 parent c9becdc commit 74ad0f8

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
@@ -540,15 +540,15 @@ func (cfg *RequestConfig) Execute() (err error) {
540540
return nil
541541
}
542542

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

554554
return nil

0 commit comments

Comments
 (0)