func (l *Logger) ModifyResponse(res *http.Response) error {
	ctx := martian.NewContext(res.Request)
	if ctx.SkippingLogging() {
		return nil
	}
	id := ctx.ID()
	lres, err := l.log.Converter.convertResponse(res)
	if err != nil {
		return err
	}
	l.mu.Lock()
	defer l.mu.Unlock()
	if e, ok := l.entries[id]; ok {
		e.Response = lres
	}
	return nil
}
ModifyResponse logs responses.
package proxy
import (
	"bytes"
	"fmt"
	"io/ioutil"
	"net/http"
	"strconv"
	"sync"
	"github.com/google/martian"
)
const LogVersion = "0.2"
type Log struct {
	Initial   []byte  
	Version   string  
	Converter *Converter
	Entries   []*Entry
}
type Entry struct {
	ID       string  
	Request  *Request
	Response *Response
}
type Request struct {
	Method string       
	URL    string       
	Header http.Header  
	MediaType string       
	BodyParts [][]byte     
	Trailer   http.Header `json:",omitempty"`  
}
type Response struct {
	StatusCode int          
	Proto      string       
	ProtoMajor int          
	ProtoMinor int          
	Header     http.Header  
	Body       []byte       
	Trailer    http.Header `json:",omitempty"`  
}
type Logger struct {
	mu      sync.Mutex
	entries map[string]*Entry  
	log     *Log
}
func newLogger() *Logger {
	return &Logger{
		log: &Log{
			Version:   LogVersion,
			Converter: defaultConverter(),
		},
		entries: map[string]*Entry{},
	}
}
func (l *Logger) ModifyRequest(req *http.Request) error {
	if req.Method == "CONNECT" {
		return nil
	}
	ctx := martian.NewContext(req)
	if ctx.SkippingLogging() {
		return nil
	}
	lreq, err := l.log.Converter.convertRequest(req)
	if err != nil {
		return err
	}
	id := ctx.ID()
	entry := &Entry{ID: id, Request: lreq}
	l.mu.Lock()
	defer l.mu.Unlock()
	if _, ok := l.entries[id]; ok {
		panic(fmt.Sprintf("proxy: duplicate request ID: %s", id))
	}
	l.entries[id] = entry
	l.log.Entries = append(l.log.Entries, entry)
	return nil
}