dnaeon / go-vcr

Record and replay your HTTP interactions for fast, deterministic and accurate tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-vcr messes with a Body set to http.NoBody

vangent opened this issue · comments

According to net/http (https://golang.org/pkg/net/http/):

http.NoBody can be used in an outgoing client request to explicitly signal that a request has zero bytes. An alternative, however, is to simply set Request.Body to nil.

recorder.go checks for r.Body != nil before inserting a new Reader (a TeeReader used to save the Body into a buffer in order to record it). However, if r.Body is http.NoBody, it still inserts the new Reader. This can result in the HTTP request being made without a Content-Length=0 header.

Fixed with #39.