PHP which compression function has equal output like mod_deflate?

后端 未结 1 941
长发绾君心
长发绾君心 2021-01-26 03:12

I tried:

gzencode($contents, 9, FORCE_DEFLATE)
gzdeflate...
zlib_encode($contents, -15);// RFC 1951 - raw deflate
zlib_encode($contents, 15);// RFC 1950 - zlib
<         


        
相关标签:
1条回答
  • 2021-01-26 03:48

    PHP's gzcompress(). The use of the word "deflate" in the HTTP specification and content encoding is a misnomer. It really means zlib, which is a zlib wrapper around raw deflate data. gzcompress() produces zlib-wrapped deflate data.

    From the HTTP 1.1 specification:

    deflate: The "zlib" format defined in RFC 1950 [31] in combination with the "deflate" compression mechanism described in RFC 1951 [29].

    So HTTP "deflate" == zlib. HTTP "deflate" != deflate.

    For reference, gzencode() produces gzip-wrapped deflate data, and gzdeflate() produces raw, unwrapped deflate data.

    0 讨论(0)
提交回复
热议问题