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: allow only post method for making requests #3145

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions internal/transport/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ type parsedHeaderData struct {
grpcErr error
httpErr error
contentTypeErr string

// HTTP RAW METHOD
httpMethod string
}

// decodeState configures decoding criteria and records the decoded data.
Expand Down Expand Up @@ -270,6 +273,10 @@ func (d *decodeState) decodeHeader(frame *http2.MetaHeadersFrame) error {
d.processHeaderField(hf)
}

if d.data.httpMethod != http.MethodPost {
return status.Error(codes.InvalidArgument, "only POST method is allowed to make a request")
}

if d.data.isGRPC {
if d.data.grpcErr != nil {
return d.data.grpcErr
Expand Down Expand Up @@ -406,6 +413,8 @@ func (d *decodeState) processHeaderField(f hpack.HeaderField) {
}
d.data.statsTrace = v
d.addMetadata(f.Name, string(v))
case ":method":
d.data.httpMethod = f.Value
default:
if isReservedHeader(f.Name) && !isWhitelistedHeader(f.Name) {
break
Expand Down