Skip to content

Commit

Permalink
Set the request.Body to http.NoBody if request.Body is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijamt authored and dnaeon committed Oct 11, 2024
1 parent e544a7e commit e0eabf6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cassette/cassette.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e0eabf6

Please sign in to comment.