CodeIgniter Forums
Services::negotiator -> gzip -> ob_gzhandler - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Services::negotiator -> gzip -> ob_gzhandler (/showthread.php?tid=77005)



Services::negotiator -> gzip -> ob_gzhandler - johannes - 07-11-2020

Good day

can somebody please tell me what is best practice to seng a gzipped stream back to client via CI4 ?\
I have the following logic todo this before a JSON string gets send back


PHP Code:
$negotiate = \Config\Services::negotiator();
$type $negotiate->encoding(['gzip']);
  if ($type == 'gzip') {
    ob_start('ob_gzhandler');
  }


//then return the json string
return $this->respondCreated($DummyDataArray); 

Is this the correct way ?
Thank you
Johannes