Skip to content

Commit

Permalink
make size limit int
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Aug 28, 2024
1 parent 721b83f commit aa3fdd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ type Client struct {
// HeaderAuthorizationKey is used to set/access Request Authorization header
// value when `SetAuthToken` option is used.
HeaderAuthorizationKey string
ResponseBodyLimit int64
ResponseBodyLimit int

jsonEscapeHTML bool
setContentLength bool
Expand Down Expand Up @@ -1100,7 +1100,7 @@ func (c *Client) SetJSONEscapeHTML(b bool) *Client {
// - "DoNotParseResponse" is set for client or request.
//
// this can be overridden at client level with [Request.SetResponseBodyLimit]
func (c *Client) SetResponseBodyLimit(v int64) *Client {
func (c *Client) SetResponseBodyLimit(v int) *Client {
c.ResponseBodyLimit = v
return c
}
Expand Down Expand Up @@ -1278,7 +1278,7 @@ var ErrResponseBodyTooLarge = errors.New("resty: response body too large")

// https://github.com/golang/go/issues/51115
// [io.LimitedReader] can only return [io.EOF]
func readAllWithLimit(r io.Reader, maxSize int64) ([]byte, error) {
func readAllWithLimit(r io.Reader, maxSize int) ([]byte, error) {
if maxSize <= 0 {
return io.ReadAll(r)
}
Expand All @@ -1289,7 +1289,7 @@ func readAllWithLimit(r io.Reader, maxSize int64) ([]byte, error) {
for {
n, err := r.Read(buf)
total += n
if int64(total) > maxSize {
if total > maxSize {
return nil, ErrResponseBodyTooLarge
}

Expand Down
4 changes: 2 additions & 2 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type Request struct {
multipartFiles []*File
multipartFields []*MultipartField
retryConditions []RetryConditionFunc
responseBodyLimit int64
responseBodyLimit int
}

// Generate curl command for the request.
Expand Down Expand Up @@ -610,7 +610,7 @@ func (r *Request) SetDoNotParseResponse(parse bool) *Request {
// - "DoNotParseResponse" is set for client or request.
//
// This will override Client config.
func (r *Request) SetResponseBodyLimit(v int64) *Request {
func (r *Request) SetResponseBodyLimit(v int) *Request {
r.responseBodyLimit = v
return r
}
Expand Down

0 comments on commit aa3fdd1

Please sign in to comment.