Skip to content

Commit

Permalink
Merge pull request #378 from projectdiscovery/fix_body_too_large_err
Browse files Browse the repository at this point in the history
fix `http: request body too large` err
  • Loading branch information
dogancanbakir committed Mar 27, 2024
2 parents eb403d4 + 7174aa3 commit 0581372
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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

0 comments on commit 0581372

Please sign in to comment.