当前位置: 首页>>代码示例>>PHP>>正文


PHP http_get_request_headers函数代码示例

本文整理汇总了PHP中http_get_request_headers函数的典型用法代码示例。如果您正苦于以下问题:PHP http_get_request_headers函数的具体用法?PHP http_get_request_headers怎么用?PHP http_get_request_headers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了http_get_request_headers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: request_headers

 /**
  * Parses the the HTTP request headers and returns an array containing
  * key value pairs. This method is slow, but provides an accurate
  * representation of the HTTP request.
  *
  *      // Get http headers into the request
  *      $request->headers = HTTP::request_headers();
  *
  * @return  HTTP_Header
  */
 public static function request_headers()
 {
     // If running on apache server
     if (function_exists('apache_request_headers')) {
         // Return the much faster method
         return new HTTP_Header(apache_request_headers());
     } elseif (extension_loaded('http')) {
         // Return the much faster method
         return new HTTP_Header(http_get_request_headers());
     }
     // Setup the output
     $headers = array();
     // Parse the content type
     if (!empty($_SERVER['CONTENT_TYPE'])) {
         $headers['content-type'] = $_SERVER['CONTENT_TYPE'];
     }
     // Parse the content length
     if (!empty($_SERVER['CONTENT_LENGTH'])) {
         $headers['content-length'] = $_SERVER['CONTENT_LENGTH'];
     }
     foreach ($_SERVER as $key => $value) {
         // If there is no HTTP header here, skip
         if (strpos($key, 'HTTP_') !== 0) {
             continue;
         }
         // This is a dirty hack to ensure HTTP_X_FOO_BAR becomes x-foo-bar
         $headers[str_replace(array('HTTP_', '_'), array('', '-'), $key)] = $value;
     }
     return new HTTP_Header($headers);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:40,代码来源:http.php

示例2: test_functions

/**
 * Test Http functions.
 */
function test_functions()
{
    http_cache_last_modified();
    http_chunked_decode();
    http_deflate();
    http_inflate();
    http_build_cookie();
    http_date();
    http_get_request_body_stream();
    http_get_request_body();
    http_get_request_headers();
    http_match_etag();
    http_match_modified();
    http_match_request_header();
    http_support();
    http_negotiate_charset();
    http_negotiate_content_type();
    http_negotiate_language();
    ob_deflatehandler();
    ob_etaghandler();
    ob_inflatehandler();
    http_parse_cookie();
    http_parse_headers();
    http_parse_message();
    http_parse_params();
    http_persistent_handles_clean();
    http_persistent_handles_count();
    http_persistent_handles_ident();
    http_get();
    http_head();
    http_post_data();
    http_post_fields();
    http_put_data();
    http_put_file();
    http_put_stream();
    http_request_body_encode();
    http_request_method_exists();
    http_request_method_name();
    http_request_method_register();
    http_request_method_unregister();
    http_request();
    http_redirect();
    http_send_content_disposition();
    http_send_content_type();
    http_send_data();
    http_send_file();
    http_send_last_modified();
    http_send_status();
    http_send_stream();
    http_throttle();
    http_build_str();
    http_build_url();
}
开发者ID:jkribeiro,项目名称:PHPHttpCompatibility,代码行数:56,代码来源:snippets.php

示例3: save

 public function save()
 {
     if (function_exists('apache_request_headers')) {
         $requestHeaders = apache_request_headers();
     } elseif (function_exists('http_get_request_headers')) {
         $requestHeaders = http_get_request_headers();
     } else {
         $requestHeaders = array();
     }
     $responseHeaders = array();
     foreach (headers_list() as $header) {
         if (($pos = strpos($header, ':')) !== false) {
             $name = substr($header, 0, $pos);
             $value = trim(substr($header, $pos + 1));
             if (isset($responseHeaders[$name])) {
                 if (!is_array($responseHeaders[$name])) {
                     $responseHeaders[$name] = array($responseHeaders[$name], $value);
                 } else {
                     $responseHeaders[$name][] = $value;
                 }
             } else {
                 $responseHeaders[$name] = $value;
             }
         } else {
             $responseHeaders[] = $header;
         }
     }
     $route = Yii::app()->getUrlManager()->parseUrl(Yii::app()->getRequest());
     $action = null;
     $actionParams = array();
     if (($ca = @Yii::app()->createController($route)) !== null) {
         /* @var CController $controller */
         /* @var string $actionID */
         list($controller, $actionID) = $ca;
         if (!$actionID) {
             $actionID = $controller->defaultAction;
         }
         if (($a = $controller->createAction($actionID)) !== null) {
             if ($a instanceof CInlineAction) {
                 $action = get_class($controller) . '::action' . ucfirst($actionID) . '()';
             } else {
                 $action = get_class($a) . '::run()';
             }
         }
         $actionParams = $controller->actionParams;
     }
     $flashes = array();
     $user = Yii::app()->getComponent('user', false);
     if ($user instanceof CWebUser) {
         $flashes = $user->getFlashes(false);
     }
     return array('flashes' => $flashes, 'statusCode' => $this->getStatusCode(), 'requestHeaders' => $requestHeaders, 'responseHeaders' => $responseHeaders, 'route' => $route, 'action' => $action, 'actionParams' => $actionParams, 'SERVER' => empty($_SERVER) ? array() : $_SERVER, 'GET' => empty($_GET) ? array() : $_GET, 'POST' => empty($_POST) ? array() : $_POST, 'COOKIE' => empty($_COOKIE) ? array() : $_COOKIE, 'FILES' => empty($_FILES) ? array() : $_FILES, 'SESSION' => empty($_SESSION) ? array() : $_SESSION);
 }
开发者ID:Orlac,项目名称:yii2-debug,代码行数:53,代码来源:Yii2RequestPanel.php

示例4: getHeaders

 /**
  * 返回header头信息
  */
 public function getHeaders()
 {
     if (function_exists('getallheaders')) {
         $headers = getallheaders();
     } elseif (function_exists('http_get_request_headers')) {
         $headers = http_get_request_headers();
     } else {
         $headers = [];
         foreach ($_SERVER as $name => $value) {
             if (substr($name, 0, 5) == 'HTTP_') {
                 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
             }
         }
     }
     return $headers;
 }
开发者ID:ybluesky,项目名称:h2o,代码行数:19,代码来源:Request.php

示例5: parseHeaders

 private function parseHeaders()
 {
     $headers = null;
     if (function_exists('http_get_request_headers')) {
         //Try to use pcre_http library if it exists
         $headers = http_get_request_headers();
     } else {
         if (function_exists('apache_request_headers')) {
             //If not: try to use apache specific headers
             $headers = apache_request_headers();
         } else {
             //If not: not supported - empty headers
             $headers = array();
         }
     }
     $this->headers = $headers;
 }
开发者ID:jpbauer,项目名称:knowledgetree,代码行数:17,代码来源:KT_atom_service.inc.php

示例6: getParams

 public static function getParams()
 {
     $params = array('fileName' => '', 'pathHash' => '', 'name' => '', 'action' => '', 'replica' => 0, 'position' => null, 'configIndex' => 0, 'moveConfigIndex' => 0, 'moveContext' => WebDFS::MOVE_CONTEXT_START, 'getContext' => '', 'propagateDelete' => 1);
     // need to create the path info if nothing exists
     if (!isset($_SERVER['PATH_INFO']) && isset($_SERVER['REDIRECT_URL'])) {
         $_SERVER['PATH_INFO'] = preg_replace('/^.*?\\/([^\\/]+)$/', '\\1', $_SERVER['REDIRECT_URL']);
     }
     if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !== '') {
         $params['action'] = strtolower($_SERVER['REQUEST_METHOD']);
         $params['name'] = trim($_SERVER['PATH_INFO'], '/');
         $params['name'] = str_replace(array('\\0'), "", $params['name']);
         $params['fileName'] = basename($params['name']);
         // hash the path info
         $params['pathHash'] = self::getPathHash($params['name']);
         $headers = http_get_request_headers();
         if (isset($headers[WebDFS::HEADER_REPLICA])) {
             $params['replica'] = (int) $headers[WebDFS::HEADER_REPLICA];
         }
         if (isset($headers[WebDFS::HEADER_POSITION])) {
             $params['position'] = (int) $headers[WebDFS::HEADER_POSITION];
         }
         if (isset($headers[WebDFS::HEADER_CONFIG_INDEX])) {
             $params['configIndex'] = (int) $headers[WebDFS::HEADER_CONFIG_INDEX];
         }
         if (isset($headers[WebDFS::HEADER_MOVE_CONTEXT])) {
             $params['moveContext'] = strtolower($headers[WebDFS::HEADER_MOVE_CONTEXT]);
         }
         if (isset($headers[WebDFS::HEADER_MOVE_CONFIG_INDEX])) {
             $params['moveConfigIndex'] = (int) $headers[WebDFS::HEADER_MOVE_CONFIG_INDEX];
         }
         if (isset($headers[WebDFS::HEADER_GET_CONTEXT])) {
             $params['getContext'] = $headers[WebDFS::HEADER_GET_CONTEXT];
         }
         if (isset($headers[WebDFS::HEADER_CONTENT_LENGTH])) {
             $params['contentLength'] = (int) $headers[WebDFS::HEADER_CONTENT_LENGTH];
         }
         if (isset($headers[WebDFS::HEADER_PROPAGATE_DELETE])) {
             $params['propagateDelete'] = (int) $headers[WebDFS::HEADER_PROPAGATE_DELETE];
         }
         if (isset($headers[WebDFS::HEADER_FORCE_DELETE])) {
             $params['forceDelete'] = (int) $headers[WebDFS::HEADER_FORCE_DELETE];
         }
     }
     return $params;
 }
开发者ID:shanehill00,项目名称:webdfs,代码行数:45,代码来源:Helper.php

示例7: readHeaders

 protected function readHeaders()
 {
     if (function_exists('apache_request_headers')) {
         // @codeCoverageIgnoreStart
         $headers = apache_request_headers();
     } elseif (function_exists('http_get_request_headers')) {
         $headers = http_get_request_headers();
     } else {
         // @codeCoverageIgnoreEnd
         $headers = array();
         foreach ($this->server() as $name => $value) {
             if (substr($name, 0, 5) == 'HTTP_') {
                 // HTTP_FOO_BAR becomes FOO-BAR
                 $name = str_replace(array('HTTP_', '_'), array('', '-'), $name);
                 $headers[$name] = $value;
             }
         }
     }
     return $this->normalizeHeaders($headers);
 }
开发者ID:otherjohn,项目名称:govid,代码行数:20,代码来源:Request.php

示例8: getHeaders

 /**
  * Returns the header collection.
  * The header collection contains incoming HTTP headers.
  * @return HeaderCollection the header collection
  */
 public function getHeaders()
 {
     if ($this->_headers === null) {
         $this->_headers = new HeaderCollection();
         if (function_exists('getallheaders')) {
             $headers = getallheaders();
         } elseif (function_exists('http_get_request_headers')) {
             $headers = http_get_request_headers();
         } else {
             foreach ($_SERVER as $name => $value) {
                 if (strncmp($name, 'HTTP_', 5) === 0) {
                     $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
                     $this->_headers->add($name, $value);
                 }
             }
             return $this->_headers;
         }
         foreach ($headers as $name => $value) {
             $this->_headers->add($name, $value);
         }
     }
     return $this->_headers;
 }
开发者ID:chenyongze,项目名称:yii2-swoole,代码行数:28,代码来源:JzRequest.php

示例9: request_headers

 public static function request_headers()
 {
     if (function_exists("apache_request_headers")) {
         return new HTTP_Header(apache_request_headers());
     } elseif (extension_loaded("http")) {
         $headers = version_compare(phpversion("http"), "2.0.0", ">=") ? \http\Env::getRequestHeader() : http_get_request_headers();
         return new HTTP_Header($headers);
     }
     $headers = array();
     if (!empty($_SERVER["CONTENT_TYPE"])) {
         $headers["content-type"] = $_SERVER["CONTENT_TYPE"];
     }
     if (!empty($_SERVER["CONTENT_LENGTH"])) {
         $headers["content-length"] = $_SERVER["CONTENT_LENGTH"];
     }
     foreach ($_SERVER as $key => $value) {
         if (strpos($key, "HTTP_") !== 0) {
             continue;
         }
         $headers[str_replace("_", "-", substr($key, 5))] = $value;
     }
     return new HTTP_Header($headers);
 }
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:23,代码来源:HTTP.php

示例10: getHeaders

 /**
  * @return array|false|null
  */
 public function getHeaders()
 {
     if ($this->_headers === null) {
         if (function_exists('getallheaders')) {
             $this->_headers = getallheaders();
         } elseif (function_exists('http_get_request_headers')) {
             $this->_headers = http_get_request_headers();
         } else {
             foreach ($_SERVER as $name => $value) {
                 if ($name = $this->_nameConver($name)) {
                     $this->_headers[$name] = $value;
                 }
             }
         }
     }
     return $this->_headers;
 }
开发者ID:inhere,项目名称:php-librarys,代码行数:20,代码来源:Client.php

示例11: header

 public function header($key = null)
 {
     $headers = http_get_request_headers();
     return is_null($key) ? $headers : $headers[$key];
 }
开发者ID:jesusslim,项目名称:partini,代码行数:5,代码来源:Input.php

示例12: createFromGlobals

 /**
  * Build the request using the (super) global variables.
  * 
  * @uses http_get_request_headers()
  * @uses http_get_request_body()
  * 
  * @return \Phpf\Request
  */
 public static function createFromGlobals()
 {
     $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
     $query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
     // Set request path
     if (isset($_SERVER['PATH_INFO'])) {
         $uri = urldecode($_SERVER['PATH_INFO']);
     } else {
         $uri = urldecode($_SERVER['REQUEST_URI']);
         // Remove query string from path
         if (false !== ($qpos = strpos($uri, '?'))) {
             $uri = substr($uri, 0, $qpos);
         }
     }
     $headers = http_get_request_headers();
     // Set request body data as per RFC 3875 4.2, 4.3
     if ('HEAD' === $method || 'POST' === $method && empty($headers['content-length'])) {
         // HEAD requests have no body - ha!
         // POST requests must have content-length
         $data = array();
     } else {
         if ('POST' === $method && isset($headers['content-type']) && 'multipart/form-data' === $headers['content-type']) {
             // Use php://input except for POST with enctype="multipart/form-data"
             // @see {@link http://us3.php.net/manual/en/wrappers.php.php}
             $data = $_POST;
         } else {
             parse_str(http_get_request_body(), $data);
         }
     }
     return new static($method, $uri, $query, $headers, $data, $_COOKIE, $_FILES);
 }
开发者ID:phpf,项目名称:micro,代码行数:39,代码来源:Request.php

示例13: http_get_request_headers

<?php

$request_headers = http_get_request_headers();
$dataType = isset($request_headers["X-File-Type"]) ? $request_headers["X-File-Type"] : "image/jpg";
echo "data:" . $dataType . ";base64," . base64_encode(http_get_request_body());
开发者ID:robertgtaylor1,项目名称:wepuzzleit,代码行数:5,代码来源:get-data-uri.php

示例14: getRequestHeaders

 public function getRequestHeaders()
 {
     if ($this->_headers === null) {
         $this->_headers = [];
         if (function_exists('getallheaders')) {
             foreach (getallheaders() as $name => $value) {
                 $this->_headers[$name] = $value;
             }
         } elseif (function_exists('http_get_request_headers')) {
             foreach (http_get_request_headers() as $name => $value) {
                 $this->_headers[$name] = $value;
             }
         } else {
             foreach ($_SERVER as $name => $value) {
                 if (strncmp($name, 'HTTP_', 5) === 0) {
                     $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
                     $this->_headers[$name] = $value;
                 }
             }
         }
     }
     return $this->_headers;
 }
开发者ID:AndreyErikin,项目名称:JsonRpc,代码行数:23,代码来源:PhpTransport.php

示例15: getHeaders

 public static function getHeaders()
 {
     $headers = array();
     if (function_exists('getallheaders')) {
         $headers = getallheaders();
     } elseif (function_exists('apache_request_headers')) {
         $headers = apache_request_headers();
     } elseif (function_exists('http_get_request_headers')) {
         $headers = http_get_request_headers();
     }
     foreach ($headers as $key => $value) {
         $key = 'HTTP_' . strtoupper(str_replace('-', '_', $key));
         if (!isset($_SERVER[$key])) {
             $_SERVER[$key] = $value;
         }
     }
     return $headers;
 }
开发者ID:admpub,项目名称:MicroPHP,代码行数:18,代码来源:AutoExpires.php


注:本文中的http_get_request_headers函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。