mozillazg / request

A developer-friendly HTTP request library for Gopher.
https://godoc.org/github.com/mozillazg/request
MIT License
426 stars 40 forks source link

How to dump outgoing request? #17

Closed wrunk closed 7 years ago

wrunk commented 8 years ago

When using regular net/http go provides a nice net/http/httputil package for dumping the outgoing request via:

httputil.DumpRequest

I'm wondering how we could optionally expose this for debugging purposes (super useful for integration tests over HTTP).

sandro commented 7 years ago

👍 I love using httputil.DumpRequest and would love to see something similar here.

mozillazg commented 7 years ago

@sandro What do you think about https://github.com/mozillazg/request/pull/18

sandro commented 7 years ago

@mozillazg I like the idea of adding hooks. It allows folks to do things beyond dumping the request, things we can't even think of right now. Very flexible. You could also export the actual http request and response structs from the request.Request and request.Response structs.

mozillazg commented 7 years ago

@sandro You can access actual http response via request.Response.Response.