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

Do we have automatic header detection? #52

Open
dinamic opened this issue Jun 25, 2024 · 2 comments
Open

Do we have automatic header detection? #52

dinamic opened this issue Jun 25, 2024 · 2 comments

Comments

@dinamic
Copy link

dinamic commented Jun 25, 2024

I'm working on a custom http client that'd support gzip as well as brotli. I'm parsing the http request headers and upon processing the headers I'm trying to apply a stream filter depending on the Content-Encoding header the server sent.

I noticed we've got automatic header detection with zlib.

See https://www.zlib.net/manual.html#Advanced definition of inflateInit2.

Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection

In this PHP this can be used as:

stream_filter_append($stream, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]);

Do we have means to do automatic header detection with Brotli?
What a suggested approach would look like?

Thanks 🙏

@dinamic dinamic changed the title Automatic header detection Do we have automatic header detection? Jun 25, 2024
@kjdev
Copy link
Owner

kjdev commented Jun 25, 2024

Unfortunately it doesn't seem to support detection of compressed files.

google/brotli#867

@dinamic
Copy link
Author

dinamic commented Jun 26, 2024

@kjdev google/brotli#867 says that the comment option was added. Doesn't this mean the magic bytes were added and could be used to detect compressed files?

Turns out I wouldn't need the functionality, but it could be a nice feature to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants