Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix http: request body too large err #378

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion http/normalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func readNNormalizeRespBody(rc *ResponseChain, body *bytes.Buffer) (err error) {
return errors.Wrap(err, "could not read response body after gzip error")
}
}
if stringsutil.ContainsAny(err.Error(), "unexpected EOF", "read: connection reset by peer", "user canceled") {
if stringsutil.ContainsAnyI(err.Error(), "unexpected EOF", "read: connection reset by peer", "user canceled", "http: request body too large") {
// keep partial body and continue (skip error) (add meta header in response for debugging)
if response.Header == nil {
response.Header = make(http.Header)
Expand Down
4 changes: 3 additions & 1 deletion http/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"fmt"
"io"
"net/http"

"github.com/docker/go-units"
)

var (
MaxBodyRead = int64(4 << 20) // 4MB
MaxBodyRead, _ = units.FromHumanSize("4mb")
)

// DumpResponseIntoBuffer dumps a http response without allocating a new buffer
Expand Down
5 changes: 3 additions & 2 deletions reader/conn_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"syscall"
"time"

"github.com/docker/go-units"
contextutil "github.com/projectdiscovery/utils/context"
errorutil "github.com/projectdiscovery/utils/errors"
)

const (
var (
// although this is more than enough for most cases
MaxReadSize = 1 << 23 // 8MB
MaxReadSize, _ = units.FromHumanSize("8mb")
)

var (
Expand Down