duanrang9348 2015-07-11 05: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 09: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}]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部