1
我有一個http請求,我需要檢查的身體。但是當我這樣做時,請求失敗。我假設這與閱讀器需要重置有關,但沿着go ioutil reset ReadCloser
的線搜索並沒有改變任何看起來很有希望的東西。在Go中,我如何重用ReadCloser?
c
是*middleware.Context
, c.Req.Request
是一個http.Request
和 c.Req.Request.Body
是io.ReadCloser
contents, _ := ioutil.ReadAll(c.Req.Request.Body)
log.Info("Request: %s", string(contents))
proxy.ServeHTTP(c.RW(), c.Req.Request)
具體來說,我得到的錯誤是http: proxy error: http: ContentLength=133 with Body length 0