Open MrXu opened 7 years ago
Seems like you're sending an incorrect Content-Length value
Hi, I don't use gin but i'm troubleshooting the same problem as your number 2, with macaron. I think in my case (and likely yours) the problem is that the macaron/gin/whatever reads the request body for post requests (it does this to load in the form variables) (and likely closes it too), and so when proxying the request, there's nothing to read in the body anymore. so body length becomes 0, but the header is still the original header. so the options are A) do proxying in such a way that the request body isn't already read when you try to proxy. B) recreate the body based on the form data C) switch the request body before it gets read the first time, by something that can be read multiple times. something like:
buffer, _ := ioutil.ReadAll(c.Req.Request.Body)
c.Req.Request.Body = ioutil.NopCloser(bytes.NewBuffer(buffer))
I'm attempting C right now.
I wrote a simple reverse proxy with Gin. The code is listed below.
http: proxy error: http: ContentLength=452831 with Body length 0
May I know what may cause this problem?