Skip to content

Commit

Permalink
Using int64 instead of uint64 for response size
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed May 15, 2015
1 parent 1ee3bc2 commit d90395c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions middleware/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
type (
Response struct {
Writer http.ResponseWriter
status int
size uint64
status int
size int64
committed bool
}
)
Expand All @@ -33,15 +33,15 @@ 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
}

func (r *Response) Status() int {
return r.status
}

func (r *Response) Size() uint64 {
func (r *Response) Size() int64 {
return r.size
}

Expand Down
2 changes: 1 addition & 1 deletion response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

0 comments on commit d90395c

Please sign in to comment.