From 96387e9a9b9e30824637c7a153311c51cc9cbc07 Mon Sep 17 00:00:00 2001 From: kbynd Date: Sat, 31 Dec 2016 16:04:34 +0530 Subject: [PATCH 1/3] EnableGZip=true,then content-length header missing This results in responses with Content-Type as gzip as opposed to original content type. This affects ServeJSON() function. --- context/output.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/context/output.go b/context/output.go index c09b9d19..7b238ab8 100644 --- a/context/output.go +++ b/context/output.go @@ -67,9 +67,9 @@ func (output *BeegoOutput) Body(content []byte) error { } if b, n, _ := WriteBody(encoding, buf, content); b { output.Header("Content-Encoding", n) - } else { - output.Header("Content-Length", strconv.Itoa(len(content))) - } + } + 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 { From f0d1d7149bfc2e4618cf5a388f795c901d9c74d0 Mon Sep 17 00:00:00 2001 From: kbynd Date: Sat, 31 Dec 2016 16:14:38 +0530 Subject: [PATCH 2/3] Update output.go --- context/output.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/context/output.go b/context/output.go index 7b238ab8..76b523d3 100644 --- a/context/output.go +++ b/context/output.go @@ -67,8 +67,11 @@ func (output *BeegoOutput) Body(content []byte) error { } if b, n, _ := WriteBody(encoding, buf, content); b { output.Header("Content-Encoding", n) - } - output.Header("Content-Length", strconv.Itoa(len(content))) + output.Header("Content-Length", strconv.Itoa(buf.Len())) + } 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" From 2f6da122fdcef15780daff6c491997fde5211c1e Mon Sep 17 00:00:00 2001 From: kbynd Date: Mon, 2 Jan 2017 09:17:17 +0530 Subject: [PATCH 3/3] Update output.go --- context/output.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/context/output.go b/context/output.go index 76b523d3..4b513dd8 100644 --- a/context/output.go +++ b/context/output.go @@ -71,8 +71,6 @@ func (output *BeegoOutput) Body(content []byte) error { } 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 {