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

distributor: fix snappy-compressed protobuf POST request handling (#3407) #3408

Merged
merged 1 commit into from
Mar 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/distributor/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ func ParseRequest(r *http.Request) (*logproto.PushRequest, error) {
switch contentEncoding {
case "":
body = lokiutil.NewSizeReader(r.Body)
case "snappy":
// Snappy-decoding is done by `util.ParseProtoReader(..., util.RawSnappy)` below.
// Pass on body bytes. Note: HTTP clients do not need to set this header,
// but they sometimes do. See #3407.
body = lokiutil.NewSizeReader(r.Body)
case "gzip":
gzipReader, err := gzip.NewReader(r.Body)
if err != nil {
Expand Down Expand Up @@ -145,6 +150,8 @@ func ParseRequest(r *http.Request) (*logproto.PushRequest, error) {
}

default:
// When no content-type header is set or when it is set to
// `application/x-protobuf`: expect snappy compression.
if err := util.ParseProtoReader(r.Context(), body, int(r.ContentLength), math.MaxInt32, &req, util.RawSnappy); err != nil {
return nil, err
}
Expand Down