mirror of
https://github.com/labstack/echo.git
synced 2025-05-13 22:06:36 +02:00
Using int64 instead of uint64 for response size
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
1ee3bc23e3
commit
d90395cf2b
@ -9,13 +9,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
gzipResponseWriter struct {
|
gzipWriter struct {
|
||||||
io.Writer
|
io.Writer
|
||||||
*echo.Response
|
*echo.Response
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g gzipResponseWriter) Write(b []byte) (int, error) {
|
func (g gzipWriter) Write(b []byte) (int, error) {
|
||||||
return g.Writer.Write(b)
|
return g.Writer.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ func Gzip() echo.MiddlewareFunc {
|
|||||||
|
|
||||||
w := gzip.NewWriter(c.Response.Writer)
|
w := gzip.NewWriter(c.Response.Writer)
|
||||||
defer w.Close()
|
defer w.Close()
|
||||||
gw := gzipResponseWriter{Writer: w, Response: c.Response}
|
gw := gzipWriter{Writer: w, Response: c.Response}
|
||||||
c.Response.Header().Set(echo.ContentEncoding, scheme)
|
c.Response.Header().Set(echo.ContentEncoding, scheme)
|
||||||
c.Response = &echo.Response{Writer: gw}
|
c.Response = &echo.Response{Writer: gw}
|
||||||
if he := h(c); he != nil {
|
if he := h(c); he != nil {
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
type (
|
type (
|
||||||
Response struct {
|
Response struct {
|
||||||
Writer http.ResponseWriter
|
Writer http.ResponseWriter
|
||||||
status int
|
status int
|
||||||
size uint64
|
size int64
|
||||||
committed bool
|
committed bool
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -33,7 +33,7 @@ func (r *Response) WriteHeader(code int) {
|
|||||||
|
|
||||||
func (r *Response) Write(b []byte) (n int, err error) {
|
func (r *Response) Write(b []byte) (n int, err error) {
|
||||||
n, err = r.Writer.Write(b)
|
n, err = r.Writer.Write(b)
|
||||||
r.size += uint64(n)
|
r.size += int64(n)
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ func (r *Response) Status() int {
|
|||||||
return r.status
|
return r.status
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Response) Size() uint64 {
|
func (r *Response) Size() int64 {
|
||||||
return r.size
|
return r.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func TestResponse(t *testing.T) {
|
|||||||
// Write & Size
|
// Write & Size
|
||||||
s := "echo"
|
s := "echo"
|
||||||
r.Write([]byte(s))
|
r.Write([]byte(s))
|
||||||
if r.Size() != len(s) {
|
if r.Size() != int64(len(s)) {
|
||||||
t.Errorf("size should be %d", len(s))
|
t.Errorf("size should be %d", len(s))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user