Skip to content

Commit 7865ba8

Browse files
fix: don't try to deserialize as json when ResponseBodyInto is []byte
1 parent c092a67 commit 7865ba8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

internal/requestconfig/requestconfig.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,15 @@ func (cfg *RequestConfig) Execute() (err error) {
535535
return nil
536536
}
537537

538-
// If the response happens to be a byte array, deserialize the body as-is.
539538
switch dst := cfg.ResponseBodyInto.(type) {
539+
// If the response happens to be a byte array, deserialize the body as-is.
540540
case *[]byte:
541541
*dst = contents
542-
}
543-
544-
err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto)
545-
if err != nil {
546-
return fmt.Errorf("error parsing response json: %w", err)
542+
default:
543+
err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto)
544+
if err != nil {
545+
return fmt.Errorf("error parsing response json: %w", err)
546+
}
547547
}
548548

549549
return nil

0 commit comments

Comments
 (0)