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 io.streams.compress.Deflate and register it in algorithms #6

Closed
wants to merge 2 commits into from

Conversation

thekid
Copy link
Member

@thekid thekid commented May 30, 2024

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding, where this is listed as one of the example values

@thekid
Copy link
Member Author

thekid commented May 30, 2024

This is dangerous as deflate in HTTP context is a misnomer and refers to zlib rather than raw deflate, see https://www.php.net/manual/de/function.gzdeflate.php#usernotes and https://stackoverflow.com/a/1579506:

  • HTTP gzip is the GZIP file format.
  • HTTP deflate is actually the ZLIB data format. (But some clients do also accept the actual DEFLATE data format for deflate.)

Maybe we should add a separate method named Compression::http() to separate the lookup by tokens used in content negotiation vs. common names:

$httpDeflate= Compression::http('deflate');
$rawDeflate= Compression::named('deflate');

Alternatively, we would register our (raw deflate) implementation as raw-deflate.

@thekid
Copy link
Member Author

thekid commented May 30, 2024

However, deflate doesn't seem to be commonly used anymore, neither MDN, nor Google, nor GitHub would even react to Accept-Encoding: deflate, simply producing uncompressed output.

Historically, "deflate" was problematic because early Microsoft IIS servers would send raw deflate data instead of zlib data (see https://stackoverflow.com/a/9186091/1218408). To work around that, it became common to just use gzip.

Source: https://stackoverflow.com/questions/7243705/what-is-the-advantage-of-gzip-vs-deflate-compression

It might be clever to not merge this pull request at all, while continuing to provide the stream implementations should people need them.

@thekid thekid closed this May 30, 2024
@thekid thekid deleted the feature/deflate-algo branch May 30, 2024 10:17
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

Successfully merging this pull request may close these issues.

1 participant