mirror of
https://github.com/aykhans/sarin.git
synced 2026-10-16 14:43:53 +00:00
fix: report one error text when a response body is too large
This commit is contained in:
4 files changed
+8
-3
No files matched your search
@@ -159,7 +159,7 @@ func (c *scriptHTTPClient) Do(r *script.HTTPRequest) (*script.HTTPResponse, erro
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, fasthttp.ErrBodyTooLarge) {
|
||||
err = types.ErrScriptHTTPBodyTooLarge
|
||||
err = types.ErrResponseBodyTooLarge
|
||||
}
|
||||
return nil, types.NewScriptHTTPRequestError(r.Method, r.URL, err)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@ func statusCodeToString(code int) string {
|
||||
|
||||
// responseErrorKey drops the local address, whose port would mint a stats entry per connection.
|
||||
func responseErrorKey(err error) string {
|
||||
if errors.Is(err, fasthttp.ErrBodyTooLarge) {
|
||||
return types.ErrResponseBodyTooLarge.Error()
|
||||
}
|
||||
|
||||
message := err.Error()
|
||||
|
||||
var opErr *net.OpError
|
||||
|
||||
@@ -17,6 +17,8 @@ var (
|
||||
)
|
||||
|
||||
ErrRemoteFileTooLarge = errors.New("remote file exceeds " + FormatByteSize(RemoteFetchLimit))
|
||||
|
||||
ErrResponseBodyTooLarge = errors.New("response body exceeds the body limit")
|
||||
)
|
||||
|
||||
type FieldParseError struct {
|
||||
@@ -415,7 +417,6 @@ var (
|
||||
ErrScriptHTTPMethodEmpty = errors.New("http method cannot be empty")
|
||||
ErrScriptHTTPURLInvalid = errors.New("URL must be an absolute http or https URL")
|
||||
ErrScriptHTTPUnknownOption = errors.New("unknown option")
|
||||
ErrScriptHTTPBodyTooLarge = errors.New("response body exceeds the body limit")
|
||||
ErrScriptJSONCycle = errors.New("cannot encode a table that contains itself")
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user