示例#1
0
文件: Request.php 项目: phpf/http
 /**
  * Build a request from the $_SERVER (and possibly $_POST) superglobal(s).
  * 
  * @return \xpl\Http\Request
  */
 public static function createFromGlobals()
 {
     $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
     $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
     if (isset($_SERVER['PATH_INFO'])) {
         $uri = $_SERVER['PATH_INFO'];
     } else {
         $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
     }
     $http = Server\Server::instance();
     $headers = $http->getRequestHeaders();
     if ('POST' === $method && $http->isMultipartFormData()) {
         // Use php://input except for POST with "multipart/form-data"
         // @see {@link http://us3.php.net/manual/en/wrappers.php.php}
         $body = $_POST;
     } else {
         if ('HEAD' === $method) {
             $body = array();
         } else {
             $body = $http->getRequestBody();
         }
     }
     return new static($method, $uri, $query, $headers, $body, $_COOKIE, $_FILES);
 }
示例#2
0
文件: functions.php 项目: phpf/http
 /**
  * Determines if $value is in the contents of $name request header.
  *
  * @param string $name		Header name, lowercase, without 'HTTP_'.
  * @param string $value		Value to search for.
  * @param bool $match_case	Whether to search case-sensitive, default false.
  * @return boolean			True if found, otherwise false.
  */
 function http_in_request_header($name, $value, $match_case = false)
 {
     return Server::instance()->inRequestHeader($name, $value, $match_case);
 }