Niels Hofmans
Niels Hofmans
@telanflow can you elaborate on which context I should set/get the value to get it to pass from `CONNECT` to the followup `GET` or `POST` request? It doesn't seem to...
I tried ```go req = req.WithContext(context.WithValue(req.Context(), "testid", testID)) ctx = ctx.WithRequest(req) ctx.Context = context.WithValue(ctx.Context, "testid", testID) return req, nil ```
@telanflow is it possible it won't propagate to the actual requests because the GET request is inside the CONNECT tunnel, hence a different proxy context perhaps? e.g. ``` CONNECT website.com:443...
@telanflow can you perhaps elaborate? Not sure what you mean; ```go proxyInstance.OnRequest().DoFunc(func(req *http.Request, ctx *mps.Context) (*http.Request, *http.Response) { logger := log.WithField("ip", req.RemoteAddr) var testID uint64 var err error // if...
But proxy context should pass on between those handlers, right?
@telanflow thanks for the quick response, but still returns nil: ```go proxyInstance.OnRequest().DoFunc(func(req *http.Request, ctx *mps.Context) (*http.Request, *http.Response) { logger := log.WithField("ip", req.RemoteAddr) var testID uint64 var err error // if...
@telanflow I've split it up to make it more clear; ```go proxyInstance.OnRequest().DoFunc(func(req *http.Request, ctx *mps.Context) (*http.Request, *http.Response) { logger := log.WithField("ip", req.RemoteAddr).WithField("method", req.Method) if req.Method != http.MethodConnect { return req,...
@telanflow : this made me think, will `Context` be propagated through `HandleConnect` and `HtttpHandler`? ```go proxyInstance := mps.NewHttpProxy() mitmHandler := mps.NewMitmHandlerWithContext(proxyInstance.Ctx) proxyInstance.HandleConnect = mitmHandler proxyInstance.HttpHandler = mitmHandler proxyInstance.OnRequest().DoFunc(...) ```
Hmm, same result with: ```go proxyInstance := mps.NewHttpProxy() proxyInstance.HandleConnect = mps.NewMitmHandlerWithContext(proxyInstance.Ctx) proxyInstance.UseFunc(func(req *http.Request, ctx *mps.Context) (*http.Response, error) { ... } ```
@telanflow sorry for bugging, but any idea?