Skip to content

Commit

Permalink
optimize: allow http head when use getonly (#1456)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jin-gou authored Dec 25, 2022
1 parent b788e66 commit c637221
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ func (req *Request) readLimitBody(r *bufio.Reader, maxBodySize int, getOnly bool
// Do not reset the request here - the caller must reset it before
// calling this method.

if getOnly && !req.Header.IsGet() {
if getOnly && !req.Header.IsGet() && !req.Header.IsHead() {
return ErrGetOnly
}

Expand All @@ -1147,7 +1147,7 @@ func (req *Request) readBodyStream(r *bufio.Reader, maxBodySize int, getOnly boo
// Do not reset the request here - the caller must reset it before
// calling this method.

if getOnly && !req.Header.IsGet() {
if getOnly && !req.Header.IsGet() && !req.Header.IsHead() {
return ErrGetOnly
}

Expand Down
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ type Server struct {
// Rejects all non-GET requests if set to true.
//
// This option is useful as anti-DoS protection for servers
// accepting only GET requests. The request size is limited
// accepting only GET requests and HEAD requests. The request size is limited
// by ReadBufferSize if GetOnly is set.
//
// Server accepts all the requests by default.
Expand Down

0 comments on commit c637221

Please sign in to comment.