在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/PHP  Linux  網(wǎng)絡(luò)安全/ http請求的header中的os_,net_參數(shù)在 php $_SERVER

http請求的header中的os_,net_參數(shù)在 php $_SERVER 無法獲取

客戶端在請求時在http請求的header中加入了一些自定義參數(shù),
但是以net_,os_,device_開頭的一些參數(shù)在后端無法獲取到。
后端使用的 php,打印$_SERVER沒有這些參數(shù)

看了http協(xié)議cgi協(xié)議也沒有找到相關(guān)說明

不太明白怎么回事

回答
編輯回答
奧特蛋

你試一下apache_request_headers() 函數(shù) 獲取一下看能夠獲取到嗎?

2017年12月21日 02:21
編輯回答
瞄小懶

找到原因了
不只是net_os_,device_開頭的一些參數(shù),默認(rèn)情況下nginx會自動drop所有帶下劃線的header
需要設(shè)置 underscores_in_headers on;

If you do not explicitly set underscores_in_headers on;, nginx will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping headers to CGI variables, as both dashes and underscores are mapped to underscores during that process.
2017年7月18日 18:42
編輯回答
陪我終

謝邀!

<?php
    header('Access-Control-Allow-Origin:*');  
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS');  
    header('Access-Control-Allow-Headers:WWW-Authenticate,Authorization,Set-Cookie,X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version'); 
    
    // 獲取頭部信息end
    $header = apache_request_headers();
    
    // 取head標(biāo)簽內(nèi)容
     var_Dump($header);exit;

?> 

獲取的時候前面要HTTP_

$_SERVER['HTTP_Authorization']
2017年6月11日 09:06