php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46577 gzip functions don't read/write mtime header
Submitted: 2008-11-15 11:34 UTC Modified: 2023-01-04 21:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mmj048 at gmail dot com Assigned:
Status: Duplicate Package: Zlib related
PHP Version: 5.2.6 OS: Windows Vista
Private report: No CVE-ID: None
 [2008-11-15 11:34 UTC] mmj048 at gmail dot com
Description:
------------
The gzencode and gzwrite functions, which implement RFC 1952 (http://www.gzip.org/zlib/rfc-gzip.html), don't read/write the mtime header.
While this is not necessary for gzip compliance (http://www.gzip.org/zlib/rfc-gzip.html#id-compliance) adding a function to read/write the mtime header when compressing or reading compressed files would be very useful in many cases.

I currently use custom code to read/write the gzip mtime header.

Read:

$gzmtime = end(unpack('V', file_get_contents($gzfile, null, null, 4, 4)));

Write:

$r = fopen($gzfile, 'r+');
fseek($r, 4);
fwrite($r, pack('V', $filemtime), 4);
fclose($r);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-08 18:23 UTC] jani@php.net
-Package: Feature/Change Request +Package: Zlib related
 [2023-01-04 20:26 UTC] cmanley at xs4all dot nl
I've added a feature request related to this here in order to set/read it via stream context options:
https://github.com/php/php-src/issues/10222
 [2023-01-04 21:22 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 07:01:26 2024 UTC