1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 04:51:30 +00:00

handle trace request must NOT CACHE

https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Cache-Control
This commit is contained in:
JessonChan 2019-03-27 13:40:34 +08:00
parent e8b29c9fd1
commit 02bead5097

View File

@ -214,6 +214,7 @@ func (c *Controller) Trace() {
hs := fmt.Sprintf("\r\nTRACE %s %s%s\r\n", c.Ctx.Request.RequestURI, c.Ctx.Request.Proto, ts(c.Ctx.Request.Header)) hs := fmt.Sprintf("\r\nTRACE %s %s%s\r\n", c.Ctx.Request.RequestURI, c.Ctx.Request.Proto, ts(c.Ctx.Request.Header))
c.Ctx.Output.Header("Content-Type", "message/http") c.Ctx.Output.Header("Content-Type", "message/http")
c.Ctx.Output.Header("Content-Length", fmt.Sprint(len(hs))) c.Ctx.Output.Header("Content-Length", fmt.Sprint(len(hs)))
c.Ctx.Output.Header("Cache-Control", "no-cache, no-store, must-revalidate")
c.Ctx.WriteString(hs) c.Ctx.WriteString(hs)
} }
@ -371,7 +372,7 @@ func (c *Controller) URLFor(endpoint string, values ...interface{}) string {
return "" return ""
} }
if endpoint[0] == '.' { if endpoint[0] == '.' {
return URLFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name() + endpoint, values...) return URLFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name()+endpoint, values...)
} }
return URLFor(endpoint, values...) return URLFor(endpoint, values...)
} }
@ -604,7 +605,7 @@ func (c *Controller) SaveToFile(fromfile, tofile string) error {
return err return err
} }
defer file.Close() defer file.Close()
f, err := os.OpenFile(tofile, os.O_WRONLY | os.O_CREATE | os.O_TRUNC, 0666) f, err := os.OpenFile(tofile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil { if err != nil {
return err return err
} }