mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 23:01:28 +00:00
router.go Header 毫无用处
context/output.go 简化一下代码,更清晰
This commit is contained in:
parent
f0474214fe
commit
6aaca2eca8
@ -66,7 +66,6 @@ func (output *BeegoOutput) Body(content []byte) {
|
|||||||
if val == "gzip" {
|
if val == "gzip" {
|
||||||
output.Header("Content-Encoding", "gzip")
|
output.Header("Content-Encoding", "gzip")
|
||||||
outputWriter, _ = gzip.NewWriterLevel(output.Context.ResponseWriter, gzip.BestSpeed)
|
outputWriter, _ = gzip.NewWriterLevel(output.Context.ResponseWriter, gzip.BestSpeed)
|
||||||
|
|
||||||
break
|
break
|
||||||
} else if val == "deflate" {
|
} else if val == "deflate" {
|
||||||
output.Header("Content-Encoding", "deflate")
|
output.Header("Content-Encoding", "deflate")
|
||||||
@ -86,11 +85,8 @@ func (output *BeegoOutput) Body(content []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outputWriter.Write(content)
|
outputWriter.Write(content)
|
||||||
switch outputWriter.(type) {
|
if c, ok := outputWriter.(io.Closer); ok {
|
||||||
case *gzip.Writer:
|
c.Close()
|
||||||
outputWriter.(*gzip.Writer).Close()
|
|
||||||
case *flate.Writer:
|
|
||||||
outputWriter.(*flate.Writer).Close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,10 +897,6 @@ type responseWriter struct {
|
|||||||
status int
|
status int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Header returns the header map that will be sent by WriteHeader.
|
|
||||||
func (w *responseWriter) Header() http.Header {
|
|
||||||
return w.ResponseWriter.Header()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write writes the data to the connection as part of an HTTP reply,
|
// Write writes the data to the connection as part of an HTTP reply,
|
||||||
// and sets `started` to true.
|
// and sets `started` to true.
|
||||||
|
Loading…
Reference in New Issue
Block a user