mirror of
https://github.com/aykhans/sarin.git
synced 2026-10-16 14:43:53 +00:00
feat: limit response body sizes
fasthttp allocates the body from the declared Content-Length before reading it, so a server could exhaust memory by declaring a size it never sends. The new max response body config bounds every response, defaults to 10MiB and accepts sizes like 10MiB or 2MB. Scripts get the same as a maxBodySize option on http().
This commit is contained in:
17 files changed
+452
-147
No files matched your search
@@ -10,6 +10,11 @@ import (
|
||||
|
||||
var (
|
||||
errNoError = errors.New("no error (internal)")
|
||||
|
||||
ErrByteSizeInvalid = errors.New(
|
||||
"invalid value for size, expected a whole number of bytes or a whole number with a unit: " +
|
||||
"B, KB, MB, GB, TB (1000 based) or KiB, MiB, GiB, TiB (1024 based), e.g. '1048576', '10MiB', '2MB'",
|
||||
)
|
||||
)
|
||||
|
||||
type FieldParseError struct {
|
||||
@@ -408,6 +413,7 @@ 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 maxBodySize")
|
||||
ErrScriptJSONCycle = errors.New("cannot encode a table that contains itself")
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user