diff --git a/htp.go b/htp.go index a6cfb9a..f5a0c39 100644 --- a/htp.go +++ b/htp.go @@ -112,7 +112,11 @@ func max(a, b int64) int64 { } func mod(x, m int64) int64 { - return (m + x%m) % m + y := x % m + if y >= 0 { + return y + } + return m + y } func noRedirect(req *http.Request, via []*http.Request) error {