MCPcopy
hub / github.com/monasticacademy/httptap / LogResp

Method LogResp

experiments/goproxy/goproxy-experiment.go:134–152  ·  view source on GitHub ↗
(resp *http.Response, ctx *goproxy.ProxyCtx)

Source from the content-addressed store, hash-verified

132}
133
134func (logger *HttpLogger) LogResp(resp *http.Response, ctx *goproxy.ProxyCtx) {
135 body := path.Join(logger.path, fmt.Sprintf("%d_resp", ctx.Session))
136 from := ""
137 if ctx.UserData != nil {
138 from = ctx.UserData.(*transport.RoundTripDetails).TCPAddr.String()
139 }
140 if resp == nil {
141 resp = emptyResp
142 } else {
143 resp.Body = NewTeeReadCloser(resp.Body, NewFileStream(body))
144 }
145 logger.LogMeta(&Meta{
146 resp: resp,
147 err: ctx.Error,
148 t: time.Now(),
149 sess: ctx.Session,
150 from: from,
151 })
152}
153
154var (
155 emptyResp = &http.Response{}

Callers 1

mainFunction · 0.80

Calls 4

LogMetaMethod · 0.95
NewTeeReadCloserFunction · 0.85
NewFileStreamFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected