Skip to content

Commit d90395c

Browse files
committed
Using int64 instead of uint64 for response size
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent 1ee3bc2 commit d90395c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

middleware/compress.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import (
99
)
1010

1111
type (
12-
gzipResponseWriter struct {
12+
gzipWriter struct {
1313
io.Writer
1414
*echo.Response
1515
}
1616
)
1717

18-
func (g gzipResponseWriter) Write(b []byte) (int, error) {
18+
func (g gzipWriter) Write(b []byte) (int, error) {
1919
return g.Writer.Write(b)
2020
}
2121

@@ -31,7 +31,7 @@ func Gzip() echo.MiddlewareFunc {
3131

3232
w := gzip.NewWriter(c.Response.Writer)
3333
defer w.Close()
34-
gw := gzipResponseWriter{Writer: w, Response: c.Response}
34+
gw := gzipWriter{Writer: w, Response: c.Response}
3535
c.Response.Header().Set(echo.ContentEncoding, scheme)
3636
c.Response = &echo.Response{Writer: gw}
3737
if he := h(c); he != nil {

response.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
type (
1111
Response struct {
1212
Writer http.ResponseWriter
13-
status int
14-
size uint64
13+
status int
14+
size int64
1515
committed bool
1616
}
1717
)
@@ -33,15 +33,15 @@ func (r *Response) WriteHeader(code int) {
3333

3434
func (r *Response) Write(b []byte) (n int, err error) {
3535
n, err = r.Writer.Write(b)
36-
r.size += uint64(n)
36+
r.size += int64(n)
3737
return n, err
3838
}
3939

4040
func (r *Response) Status() int {
4141
return r.status
4242
}
4343

44-
func (r *Response) Size() uint64 {
44+
func (r *Response) Size() int64 {
4545
return r.size
4646
}
4747

response_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestResponse(t *testing.T) {
3434
// Write & Size
3535
s := "echo"
3636
r.Write([]byte(s))
37-
if r.Size() != len(s) {
37+
if r.Size() != int64(len(s)) {
3838
t.Errorf("size should be %d", len(s))
3939
}
4040
}

0 commit comments

Comments
 (0)