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

Add support for HTTP encodings #7915

Merged
merged 1 commit into from
Aug 13, 2018

Conversation

adriansr
Copy link
Contributor

@adriansr adriansr commented Aug 8, 2018

This patch adds support for decoding HTTP bodies based on the Content-Encoding and Transfer-Encoding headers. Supported decoders are gzip and deflate.

Multiple encoders are supported, for example:

Content-Encoding: gzip
Transfer-Encoding: chunked

Or the rarely used but allowed by the standard:

Transfer-Encoding: deflate, gzip

The difference between Transfer-Encoding and Content-Encoding is not relevant to packetbeat, so both are treated the same, with the exception that chunked can only appear as the last or only element of Transfer-Encoding.

To avoid decompression bombs, the value specified in http.max_message_size (default 10MB) is honored when decoding.

A new configuration option, decode_body (default true), has been added to the http protocol, allowing to disable this feature.

io.Reader
}

func (_ closeDecorator) Close() error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receiver name should not be an underscore, omit the name if it is unused

@adriansr adriansr force-pushed the feature/pb/encoding branch 3 times, most recently from 3c0b500 to 755e9dd Compare August 8, 2018 16:36
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good + lot's of tests cases 👍 .

I think we need to add some new information to the packetbeat documenation explaining the behavior for these header types.

And add a CHANGELOG entry.

@adriansr adriansr force-pushed the feature/pb/encoding branch 3 times, most recently from 76bc67b to 046355a Compare August 10, 2018 13:09
andrewkroh
andrewkroh previously approved these changes Aug 10, 2018
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrewkroh
Copy link
Member

Needs a make update.

This patch adds support for decoding HTTP bodies based on the
`Content-Encoding` and `Transfer-Encoding` headers. Supported decoders
are `gzip` and `deflate`.

Multiple encoders are supported, for example:
```
Content-Encoding: gzip
Transfer-Encoding: chunked
```

Or the rarely used but allowed by the standard:

```
Transfer-Encoding: deflate, gzip
```

The difference between `Transfer-Encoding` and `Content-Encoding` is not
relevant to packetbeat, so both are treated the same, with the exception
that `chunked` can only appear as the last or only element of
`Transfer-Encoding`.

To avoid decompression bombs, the value specified in `http.max_message_size`
(default 10MB) is honored when decoding.

A new configuration option, `decode_body` (default true), has been added
to the http protocol, allowing to disable this feature.
@adriansr adriansr force-pushed the feature/pb/encoding branch from 046355a to d1e686b Compare August 10, 2018 14:10
@adriansr adriansr dismissed andrewkroh’s stale review August 13, 2018 09:03

Changed after review

@adriansr
Copy link
Contributor Author

Hi @andrewkroh , I updated the PR and added a new configuration option and docs

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrewkroh andrewkroh merged commit 03f7e87 into elastic:master Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants