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

optimize: allow http head when use getonly #1456

Merged
merged 1 commit into from Dec 25, 2022
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
4 changes: 2 additions & 2 deletions http.go
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
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