duanrang9348 2015-07-11 13:04
浏览 67
已采纳

无法使用Slim Framework读取“Authorization”HTTP标头

I'm trying to send "Authorization" in the header of a GET request.

In the REST Server, I'm using Slim Framework, and I'm trying to read headers with:

$app->request()->headers()->all();

this perfectly works, but I can't see the "Authorization" field.

I tried to put a "test" field in the request and I can see it. How can I solve this?

I also tried with:

apache_request_headers();

but the result is not different.

  • 写回答

1条回答 默认 最新

  • dopmgo4707 2015-07-12 17:41
    关注

    If you are sending something else than valid HTTP Basic Authorization header, PHP will not have access to it. You can work around this by adding the following rewrite rule to your .htaccess file.

    RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记