예제 #1
0
 /**
  * Compress body content
  *
  * @param Response $response
  * @param type $encoding
  * @param type $method
  * @return type
  */
 public function compressBody(Response $response, $encoding, $method)
 {
     $response = $response->withHeader('content-encoding', $encoding);
     // Thanks to Logan Bailey
     $content = $response->getBody()->__toString();
     $string = $method($content);
     // Replace the whole content
     $body = new \Zend\Diactoros\Stream('php://temp', 'rw+');
     $body->write($string);
     return $response->withBody($body);
 }
예제 #2
0
 /**
  * @param $data
  * @return \Zend\Diactoros\Stream
  */
 protected function toStream($data)
 {
     $stream = new \Zend\Diactoros\Stream("php://temp", "w");
     $stream->write($data);
     return $stream;
 }