Re: function ob_gzhandler is missed in 5.4

From: Date: Fri, 18 Nov 2011 19:11:19 +0000
Subject: Re: function ob_gzhandler is missed in 5.4
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-56409@lists.php.net to get a copy of this message
On Fri, 18 Nov 2011 12:46:05 +0100, Nicolas Grekas wrote: > Without a real ob_gzhandler function, replacing it with an alias as > currently in RC1 : what if someone then creates an ob_gzhandler function > in userland ? would ob_start('ob_gzhandler') use the userland function > or still the alias ? I think this is a second argument to make > ob_gzhandler a real function : least surprise. Why make others suffer, just if you want to? > > Personally, I do use ob_gzhandler directly because it's the easiest way > to do chunked compressed encoding in userland. > > This allows me to ask for compression as late as possible, because > registering an ob_start('ob_gzhandler'); may be too early for me. I do > want to choose to enable compression only when the very first byte is > about to be sent over the wire. > > Hope it helps > > Nicolas > > <?php > > function my_ob_handler($buffer, $mode) > { > // based on content-type, > // do some $buffer filtering // and add some header() > > if (/* content-type benefits compression based on some userland rules > */) { > $buffer = ob_gzhandler($buffer, $mode); // benefits from gzip > negotiation, chunked compression and related headers > > if (PHP_OUTPUT_HANDLER_START & $mode) > { > // play/fix with Vary: header, as sent by ob_gzhandler or before } > } > > return $buffer; > } Looks like a bad hack, but anyway, here's is another hack [1]. It's a patch for ext/zlib, which should make your hack work again... whoever might find worth the hassle, may commit it... or insist on me to do so... Regards, Mike [1] http://dev.iworks.at/PATCHES/ob_gzhandler.diff.txt

« previous php.internals (#56409) next »