mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Export: Remove no-store headers in pdf and image previews (#78844)
This commit is contained in:
parent
10cc3321cd
commit
864d91ed3e
@ -89,5 +89,6 @@ func (hs *HTTPServer) RenderToPng(c *contextmodel.ReqContext) {
|
||||
}
|
||||
|
||||
c.Resp.Header().Set("Content-Type", "image/png")
|
||||
c.Resp.Header().Set("Cache-Control", "private")
|
||||
http.ServeFile(c.Resp, c.Req, result.FilePath)
|
||||
}
|
||||
|
@ -49,7 +49,9 @@ func AddDefaultResponseHeaders(cfg *setting.Cfg) web.Handler {
|
||||
resourceCachable := resourceURLMatch && allowCacheControl(c.Resp)
|
||||
if !strings.HasPrefix(c.Req.URL.Path, "/public/plugins/") &&
|
||||
!strings.HasPrefix(c.Req.URL.Path, "/avatar/") &&
|
||||
!strings.HasPrefix(c.Req.URL.Path, "/api/datasources/proxy/") && !resourceCachable {
|
||||
!strings.HasPrefix(c.Req.URL.Path, "/api/datasources/proxy/") &&
|
||||
!strings.HasPrefix(c.Req.URL.Path, "/api/reports/render/") &&
|
||||
!strings.HasPrefix(c.Req.URL.Path, "/render/d-solo/") && !resourceCachable {
|
||||
addNoCacheHeaders(c.Resp)
|
||||
}
|
||||
|
||||
|
@ -190,6 +190,22 @@ func TestMiddlewareContext(t *testing.T) {
|
||||
"X-Other-Header": "other-test",
|
||||
}
|
||||
})
|
||||
|
||||
middlewareScenario(t, "middleware should not add Cache-Control header for requests to render pdf", func(
|
||||
t *testing.T, sc *scenarioContext) {
|
||||
sc.fakeReq("GET", "/api/reports/render/pdf/").exec()
|
||||
assert.Empty(t, sc.resp.Header().Get("Cache-Control"))
|
||||
assert.Empty(t, sc.resp.Header().Get("Pragma"))
|
||||
assert.Empty(t, sc.resp.Header().Get("Expires"))
|
||||
})
|
||||
|
||||
middlewareScenario(t, "middleware should not add Cache-Control header for requests to render panel as image", func(
|
||||
t *testing.T, sc *scenarioContext) {
|
||||
sc.fakeReq("GET", "/render/d-solo/").exec()
|
||||
assert.Empty(t, sc.resp.Header().Get("Cache-Control"))
|
||||
assert.Empty(t, sc.resp.Header().Get("Pragma"))
|
||||
assert.Empty(t, sc.resp.Header().Get("Expires"))
|
||||
})
|
||||
}
|
||||
|
||||
func middlewareScenario(t *testing.T, desc string, fn scenarioFunc, cbs ...func(*setting.Cfg)) {
|
||||
|
Loading…
Reference in New Issue
Block a user