func DumpTo(handler http.Handler, writer io.Writer) http.Handler {
	if handler == nil {
		handler = http.DefaultServeMux
	}
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		dump, err := httputil.DumpRequest(r, true)
		if err != nil {
			_, _ = fmt.Fprintf(writer, "error dumping request: %#v", err)
		} else {
			_, _ = writer.Write(append(dump, []byte("\r\n")...))
		}
		ex := Exchange{}
		w = httpsnoop.Wrap(w, hooks(&ex))
		handler.ServeHTTP(w, r)
		resp := http.Response{
			Proto:         r.Proto,
			ProtoMajor:    r.ProtoMajor,
			ProtoMinor:    r.ProtoMinor,
			StatusCode:    ex.StatusCode,
			Header:        w.Header(),
			Body:          ioutil.NopCloser(bytes.NewReader(ex.ResponseBody.Bytes())),
			ContentLength: int64(ex.ResponseBody.Len()),
		}
		d, err := httputil.DumpResponse(&resp, true)
		if err != nil {
			_, _ = fmt.Fprintf(writer, "error dumping response: %#v", err)
		} else {
			_, _ = writer.Write(append(d, []byte("\r\n")...))
		}
	})
}
DumpTo wraps an http.Handler in a new handler.  The new handler dumps requests and responses to
a writer, using the httputil.DumpRequest and httputil.DumpResponse functions.
package httptestutil
import (
	"bytes"
	"fmt"
	"github.com/felixge/httpsnoop"
	"io"
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"net/http/httputil"
	"os"
)