Open PeterYangs opened 11 months ago
package main import ( "errors" "github.com/go-resty/resty/v2" ) func main() { client := resty.New() client.OnBeforeResponse(func(client *resty.Client, response *resty.Response) error { if response.Size() > 1073741824 { return errors.New("file is too big") } return nil }).R().SetOutput("/path/123.zip").Get("http://www.ooxx.com/123.zip") }
I want to determine the size of the content before parsing the Response, and throw an error if it exceeds my preset size.
This can help you https://github.com/gospider007/requests/blob/master/test/middleware/requestCallback_test.go
I want to determine the size of the content before parsing the Response, and throw an error if it exceeds my preset size.