Ejemplo n.º 1
0
 public function testGzipDeflate()
 {
     $_SERVER['HTTP_ACCEPT_ENCODING'] = 'deflate';
     $_SERVER['HTTP_USER_AGENT'] = false;
     $encoder = new Scaffold_Response_Encoder(1);
     $content = 'foo';
     $content = $encoder->compress($content);
     $this->assertEquals($content, gzdeflate('foo', 1));
 }
Ejemplo n.º 2
0
 /**
  * Sets the output for the response
  * @access public
  * @param $content
  * @param $last_modified
  * @param $type
  * @return array
  */
 public function set($content, $last_modified, $type = 'text/plain')
 {
     $this->output = $content;
     $this->headers['Content-Type'] = $type;
     $this->headers['Expires'] = $this->_time(time() + 31536000);
     $this->headers['Last-Modified'] = $this->_time($last_modified);
     $this->headers['Cache-Control'] = $this->options['cache_control'];
     if ($this->encoding !== false) {
         $this->output = $this->encoder->encode($content);
     }
     if ($this->options['set_etag'] === true) {
         $this->headers['ETag'] = $this->generate_etag($this->output);
     }
 }
Ejemplo n.º 3
0
 /**
  * Sets the output for the response
  * @access public
  * @param $content
  * @param $last_modified
  * @param $type
  * @return array
  */
 public function set($content, $last_modified, $type = 'text/plain')
 {
     $this->output = $content;
     $this->headers['Content-Type'] = $type;
     $this->headers['Expires'] = $this->_time(time() + 31536000);
     $this->headers['Last-Modified'] = $this->_time($last_modified);
     $this->headers['Cache-Control'] = $this->options['scope'];
     # If we're manually encoding the content
     if ($this->encoding !== false) {
         $this->output = $this->encoder->encode($content);
         $this->headers['Content-Encoding'] = $this->encoding;
         $this->headers['Vary'] = 'Accept-Encoding';
     }
     # If you're letting Apache doe the encoding, it will calculate this and override it
     # Sending Content-Length in CGI can result in unexpected behavior
     if ($this->options['set_content_length'] === true and stripos(PHP_SAPI, 'cgi') !== true) {
         $this->headers['Content-Length'] = strlen($content);
     }
     # You may want to set an etag
     if ($this->options['set_etag'] === true) {
         $this->headers['ETag'] = $this->generate_etag($last_modified, $this->headers['Content-Length'], $this->encoding);
     }
 }