Skip to content

Commit

Permalink
fix: allow only post method for making requests fixes: grpc#2881
Browse files Browse the repository at this point in the history
  • Loading branch information
oneslash authored and Sardorbek Pulatov committed Nov 5, 2019
1 parent 583401a commit c981e73
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/transport/http_util.go
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

0 comments on commit c981e73

Please sign in to comment.