iris icon indicating copy to clipboard operation
iris copied to clipboard

[BUG]AccessLog.ResponseBody affects the result of the httputil.ReverseProxy

Open tuhao1020 opened this issue 3 years ago • 0 comments

code snippet:

app := iris.New()

ac := accesslog.File("./access.log")
ac.TimeFormat = "2006-01-02 15:04:05.000"
ac.Async = true
ac.ResponseBody = true
app.UseRouter(ac.Handler)

app.Get("/proxy/{p:path}", func(ctx iris.Context) {
  targetPath := ctx.Params().Get("p")
  u, _ := url.Parse("http://t0.tianditu.gov.cn/" + targetPath)
  proxy := host.ProxyHandlerRemote(u, true)
  proxy.ServeHTTP(ctx.ResponseWriter(), ctx.Request())
})

app.Listen(":8080")

if ac.ResponseBody set to true, I will get a blank page when request to /proxy/*

request url: http://localhost:8080/proxy/img_c/wmts?tk=17a1ad415ea7cd473fb96098836c8a61&REQUEST=GetCapabilities&SERVICE=WMTS

target url: http://t0.tianditu.gov.cn/img_c/wmts?tk=17a1ad415ea7cd473fb96098836c8a61&REQUEST=GetCapabilities&SERVICE=WMTS

expected: image

tuhao1020 avatar Mar 10 '21 04:03 tuhao1020