mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +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 (
|
||||
gzipResponseWriter struct {
|
||||
gzipWriter struct {
|
||||
io.Writer
|
||||
*echo.Response
|
||||
}
|
||||
)
|
||||
|
||||
func (g gzipResponseWriter) Write(b []byte) (int, error) {
|
||||
func (g gzipWriter) Write(b []byte) (int, error) {
|
||||
return g.Writer.Write(b)
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ func Gzip() echo.MiddlewareFunc {
|
||||
|
||||
w := gzip.NewWriter(c.Response.Writer)
|
||||
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 = &echo.Response{Writer: gw}
|
||||
if he := h(c); he != nil {
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
type (
|
||||
Response struct {
|
||||
Writer http.ResponseWriter
|
||||
status int
|
||||
size uint64
|
||||
status int
|
||||
size int64
|
||||
committed bool
|
||||
}
|
||||
)
|
||||
@ -33,7 +33,7 @@ func (r *Response) WriteHeader(code int) {
|
||||
|
||||
func (r *Response) Write(b []byte) (n int, err error) {
|
||||
n, err = r.Writer.Write(b)
|
||||
r.size += uint64(n)
|
||||
r.size += int64(n)
|
||||
return n, err
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ func (r *Response) Status() int {
|
||||
return r.status
|
||||
}
|
||||
|
||||
func (r *Response) Size() uint64 {
|
||||
func (r *Response) Size() int64 {
|
||||
return r.size
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ func TestResponse(t *testing.T) {
|
||||
// Write & Size
|
||||
s := "echo"
|
||||
r.Write([]byte(s))
|
||||
if r.Size() != len(s) {
|
||||
if r.Size() != int64(len(s)) {
|
||||
t.Errorf("size should be %d", len(s))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user