示例#1
0
 /**
  * DEPRECATION WARNING! Access `headers` property directly.
  *
  * Get and set header
  * @param  string      $name  Header name
  * @param  string|null $value Header value
  * @return string      Header value
  */
 public function header($name, $value = null)
 {
     if (!is_null($value)) {
         $this->headers->set($name, $value);
     }
     return $this->headers->get($name);
 }
示例#2
0
 /**
  * Get User Agent
  * @return string|null
  */
 public function getUserAgent()
 {
     return $this->headers->get('HTTP_USER_AGENT');
 }
示例#3
0
 /**
  * Return a UrlInfo instance if the request contains forwarding information, or null if not.
  *
  * First we look for the standard 'Forwarded' header from RFC 7239, then for the non-standard X-Forwarded-... headers.
  *
  * @param \Slim\Http\Headers $headers
  * @return null|UrlInfo
  */
 protected function getForwardingInfo(\Slim\Http\Headers $headers)
 {
     $info = null;
     $forwarded = $headers->get('Forwarded');
     if (!is_null($forwarded)) {
         $info = new UrlInfo($forwarded);
     } else {
         $fhost = $headers->get('X-Forwarded-Host');
         $fproto = $headers->get('X-Forwarded-Proto');
         if (!is_null($fhost)) {
             $info = new UrlInfo($fhost, $fproto);
         }
     }
     return $info;
 }
 public function testGetNotExists()
 {
     $h = new Headers();
     $this->assertNull($h->get('Foo'));
 }