Commit a9881388 authored by JessonChan's avatar JessonChan

accept encoder header setting fixed

parent 1200b7c3
......@@ -23,7 +23,6 @@ import (
"strconv"
"strings"
"fmt"
"io/ioutil"
)
......@@ -50,7 +49,6 @@ func writeLevel(encoding string, writer io.Writer, content []byte, level int) (b
var outputWriter io.Writer
var err error
if cf, ok := encoderMap[encoding]; ok {
fmt.Println("write level", encoding)
outputWriter, err = cf.encode(writer, level)
} else {
encoding = ""
......
......@@ -52,23 +52,24 @@ func (output *BeegoOutput) Header(key, val string) {
// if EnableGzip, compress content string.
// it sends out response body directly.
func (output *BeegoOutput) Body(content []byte) {
outputWriter := output.Context.ResponseWriter.(io.Writer)
var encoding string
var buf = &bytes.Buffer{}
if output.EnableGzip {
encoding = ParseEncoding(output.Context.Input.Request)
}
if b, n, _ := WriteBody(encoding, outputWriter, content); b {
if b, n, _ := WriteBody(encoding, buf, content); b {
output.Header("Content-Encoding", n)
} else {
output.Header("Content-Length", strconv.Itoa(len(content)))
}
// Write status code if it has been set manually
// Set it to 0 afterwards to prevent "multiple response.WriteHeader calls"
if output.Status != 0 {
output.Context.ResponseWriter.WriteHeader(output.Status)
output.Status = 0
}
io.Copy(output.Context.ResponseWriter, buf)
}
// Cookie sets cookie value via given key.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment