(resp *http.Response, ctx *goproxy.ProxyCtx)
| 132 | } |
| 133 | |
| 134 | func (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 | |
| 154 | var ( |
| 155 | emptyResp = &http.Response{} |
no test coverage detected