From e0eabf67b1364a47a61af2dc89b4146a5dd8afbf Mon Sep 17 00:00:00 2001 From: Ilija Matoski Date: Fri, 11 Oct 2024 12:26:44 +0200 Subject: [PATCH] Set the request.Body to http.NoBody if request.Body is nil --- pkg/cassette/cassette.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/cassette/cassette.go b/pkg/cassette/cassette.go index 6543a29..20d5825 100644 --- a/pkg/cassette/cassette.go +++ b/pkg/cassette/cassette.go @@ -459,6 +459,11 @@ func (c *Cassette) GetInteraction(r *http.Request) (*Interaction, error) { func (c *Cassette) getInteraction(r *http.Request) (*Interaction, error) { c.Lock() defer c.Unlock() + if r.Body == nil { + // causes an error in the matcher when we try to do r.ParseForm if r.Body is nil + // r.ParseForm returns missing form body error + r.Body = http.NoBody + } for _, i := range c.Interactions { if (c.ReplayableInteractions || !i.replayed) && c.Matcher(r, i.Request) { i.replayed = true