jarcoal / httpmock

HTTP mocking for Golang
http://godoc.org/github.com/jarcoal/httpmock
MIT License
1.93k stars 103 forks source link

Default/Zero-Value Request.Method not respected #47

Closed NfNitLoop closed 5 years ago

NfNitLoop commented 6 years ago

The documentation for Request.Method says: "For client requests an empty string means GET".

But in transport.go, the bare Request.Method gets used, without defaulting to "GET" if the Method is "". This means that if RoundTrip receives an http.Request which has a zero-value .Method, it can't properly look up any GET responders for that request.

The error message from http is a bit misleading:

Get https://my.example.com/endpoint?my_var=my_value: no responder found, makes it look like httpmock doesn't support matching URLs with parameters. Thankfully, after reading the source, I found that it does. (yay!) :)