• <small id='M17SP'></small><noframes id='M17SP'>

      • <bdo id='M17SP'></bdo><ul id='M17SP'></ul>
      <legend id='M17SP'><style id='M17SP'><dir id='M17SP'><q id='M17SP'></q></dir></style></legend>

      1. <i id='M17SP'><tr id='M17SP'><dt id='M17SP'><q id='M17SP'><span id='M17SP'><b id='M17SP'><form id='M17SP'><ins id='M17SP'></ins><ul id='M17SP'></ul><sub id='M17SP'></sub></form><legend id='M17SP'></legend><bdo id='M17SP'><pre id='M17SP'><center id='M17SP'></center></pre></bdo></b><th id='M17SP'></th></span></q></dt></tr></i><div id='M17SP'><tfoot id='M17SP'></tfoot><dl id='M17SP'><fieldset id='M17SP'></fieldset></dl></div>

      2. <tfoot id='M17SP'></tfoot>

        如何访问未出现在 $_SERVER 中的请求标头?

        How can I access request headers that don#39;t appear in $_SERVER?(如何访问未出现在 $_SERVER 中的请求标头?)

          <tfoot id='rOjpy'></tfoot>
          <legend id='rOjpy'><style id='rOjpy'><dir id='rOjpy'><q id='rOjpy'></q></dir></style></legend>

                <bdo id='rOjpy'></bdo><ul id='rOjpy'></ul>
              • <small id='rOjpy'></small><noframes id='rOjpy'>

              • <i id='rOjpy'><tr id='rOjpy'><dt id='rOjpy'><q id='rOjpy'><span id='rOjpy'><b id='rOjpy'><form id='rOjpy'><ins id='rOjpy'></ins><ul id='rOjpy'></ul><sub id='rOjpy'></sub></form><legend id='rOjpy'></legend><bdo id='rOjpy'><pre id='rOjpy'><center id='rOjpy'></center></pre></bdo></b><th id='rOjpy'></th></span></q></dt></tr></i><div id='rOjpy'><tfoot id='rOjpy'></tfoot><dl id='rOjpy'><fieldset id='rOjpy'></fieldset></dl></div>
                    <tbody id='rOjpy'></tbody>
                1. 本文介绍了如何访问未出现在 $_SERVER 中的请求标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 PHP 中创建一个 REST API,并且我想实现一个类似于 Amazon 的 S3 方法的身份验证方案.这涉及在请求中设置自定义授权"标头.

                  I am attempting to create a REST API in PHP and I'd like to implement an authentication scheme similar to Amazon's S3 approach. This involves setting a custom 'Authorization' header in the request.

                  我原以为可以使用 $_SERVER['HTTP_AUTHORIZATION'] 访问标头,但在 var_dump($_SERVER) 中找不到它.apache_request_headers() 函数可以解决我的问题,但是我的主机将 PHP 实现为 CGI,所以它不可用.

                  I had thought I would be able to access the header with $_SERVER['HTTP_AUTHORIZATION'], but it's nowhere to be found in var_dump($_SERVER). The apache_request_headers() function would solve my problem, but my host implements PHP as CGI, so it's unavailable.

                  还有其他方法可以访问 PHP 中的完整请求标头吗?

                  Is there another way I can access the complete request headers in PHP?

                  推荐答案

                  你需要做一些 mod_rewrite 魔法来让你的标题通过 CGI 障碍,像这样:

                  You'll need to do some mod_rewrite wizardry to get your headers past the CGI barrier, like so:

                  RewriteEngine on
                  RewriteRule .? - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
                  
                  <?php
                      $auth = $_SERVER['HTTP_AUTHORIZATION'];
                  ?>
                  

                  请注意,如果您将 mod_rewrite 用于其他目的,它最终可能是 $_SERVER['REDIRECT_HTTP_AUTHORIZATION'].

                  Note that if you're using mod_rewrite for other purposes, it could end up being $_SERVER['REDIRECT_HTTP_AUTHORIZATION'].

                  这篇关于如何访问未出现在 $_SERVER 中的请求标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                  Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)

                      <i id='WnVf4'><tr id='WnVf4'><dt id='WnVf4'><q id='WnVf4'><span id='WnVf4'><b id='WnVf4'><form id='WnVf4'><ins id='WnVf4'></ins><ul id='WnVf4'></ul><sub id='WnVf4'></sub></form><legend id='WnVf4'></legend><bdo id='WnVf4'><pre id='WnVf4'><center id='WnVf4'></center></pre></bdo></b><th id='WnVf4'></th></span></q></dt></tr></i><div id='WnVf4'><tfoot id='WnVf4'></tfoot><dl id='WnVf4'><fieldset id='WnVf4'></fieldset></dl></div>
                    1. <small id='WnVf4'></small><noframes id='WnVf4'>

                      <tfoot id='WnVf4'></tfoot>

                          <legend id='WnVf4'><style id='WnVf4'><dir id='WnVf4'><q id='WnVf4'></q></dir></style></legend>
                            <bdo id='WnVf4'></bdo><ul id='WnVf4'></ul>
                              <tbody id='WnVf4'></tbody>