Yngvarr

Generation

generate functionSat, 07 Jan 2023

gzencode and stream http archive

// // usage: curl http://localhost/gzencode.php/foo/bar // // flush gzip buffer to stream $gzip = function($data) { $flush = function() { global $gzip; $data = gzgetc(); if ($data === false) { return false; } echo $data; $gzip->flush(); return true; }; gzwrite($data); return $flush(); }; // setup gzip $gzip = gzopen('php://output', 'wb9'); // flush some data $gzip('foo'); // close stream gzclose($gzip);

Questions about programming?Chat with your personal AI assistant