-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panic in context.go #298
Comments
Ok, this looks like it's happening in the via_modifier when it detects a request loop - the call to context.Get from ModifyResponse is incorrect (it does not return an error, but an ok value) I should have a fix for you shortly. |
I finally found out the real reason behind the panic. req1 := http.NewRequest(...)
resp, err := http.DefaultTransport.RoundTrip(req1)
// sometimes resp.Request != req1 I try to figure out when the request will be changed and found that if the roundtrip failed it will retry in some cases. But the request will be recreated before retry. Checking the code at https://github.com/golang/go/blob/249c85d3aab2ad2d0bcbf36efe606fdd66f25c72/src/net/http/transport.go#L582 , you will see what I mean. I make a pr to solve the bug. It simply add a line after roundtrip.
|
Oh ok - this seems like it should work fine. Just want to note that the net/http docs say about Response.Request:
But I don't see how setting it here would cause any problems. @admtnnr @hueich can you think of any reason that setting this here would be problematic? |
I use martian in my private project and it saved me great efforts to build my own mitm proxy.
But I encounter a panic in
context.go
. The panic stack are as follows:That's was the completely call stack and I can't reproduce the error stably。I try to trace the error,
it seems that
NewContext
method incontext.go
returned a nil Context, which caused the nil pointer reference panic. But I have no idea why thectxs
has no desired Request。I use martian in my project like that:
Thanks for any response.
The text was updated successfully, but these errors were encountered: