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.

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;
}

Reply via email to