我在AJAX调用中发送客户头,
$.ajaxSetup( {
data: {csrf_token : csrf},
headers: {"Csrf_token" : csrf}
});
以下是我在请求标题中看到的内容
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Content-Length:325
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:ci_session=kd817592v16s0p5b2f502hg39rs7olnu; csrf_cookie=22a1c908f3f036c90c2d0bf0f9b19497
Csrf_token:22a1c908f3f036c90c2d0bf0f9b19497
Host:testurl.com
Origin:http://testurl.com
Pragma:no-cache
Referer:http://testurl.com/xxx
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
X-Requested-With:XMLHttpRequest
但是当我用PHP打印它时它只返回下面,我看不到我的自定义标题“Csrf_token”
> Array ( [X-Forwarded-For] => 57.73.33.1 [Cookie] =>
> `ci_session=kd817592v16s0p5b2f502hg39rs7olnu;
> csrf_cookie=22a1c908f3f036c90c2d0bf0f9b19497 [Accept-Language] =>
> en-GB,en-US;q=0.8,en;q=0.6 [Accept-Encoding] => gzip, deflate
> [Referer] => http://testurl.com/xxx [X-Requested-With] =>
> XMLHttpRequest [Accept] => */* [Content-Type] =>
> application/x-www-form-urlencoded; charset=UTF-8 [User-Agent] =>
> Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like
> Gecko) Chrome/54.0.2840.99 Safari/537.36 [Origin] =>
> http://testurl.com[Cache-Control] => no-cache [Pragma] => no-cache
> [Content-Length] => 325 [Connection] => close [Host] => testurl.com )`
如何在PHP中获取该客户标头?我正在使用codeigniter,
答案 0 :(得分:0)
使用此
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
x-li-request-id: XXXXXXXXXX
Location: https://api.linkedin.com/v1/pal/people/~/network/updates/key=UPDATE-XXXXXXX-XXXXXXXXXXXXXXXXXXX
Vary: *
x-li-format: json
Content-Type: application/json;charset=UTF-8
Date: Thu, 01 Dec 2016 10:59:59 GMT
X-Li-Fabric: prod-lva1
Transfer-Encoding: chunked
X-Li-Pop: PROD-IDB2
Set-Cookie: lidc="b=VB74:g=524:u=127:i=1480590000:t=1480675453:s=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; Expires=Fri, 02 Dec 2016 10:44:13 GMT; domain=.linkedin.com; Path=/
X-LI-UUID: XXXXXXXXXXXXXXXXXXXXXXXX
{
"updateKey": "UPDATE-XXXXXXX-XXXXXXXXXXXXXXXXXXX",
"updateUrl": "https://www.linkedin.com/updates?discuss=&scope=XXXXXXX&stype=M&topic=XXXXXXXXXXXXXXXXXXX&type=U&a=6sBt"
}
link:https://www.codeigniter.com/user_guide/libraries/input.html#CI_Input::get_request_header
答案 1 :(得分:0)
我只有下面的输出,
$.ajaxSetup( {
data: {csrf_token : csrf},
headers: {"csrf-token" : csrf, "csrf_token1" : csrf}
});
它不会使用_ name打印值,但可以使用 - names打印。
Csrf-Token:" 22a1c908f3f036werc90c2d0bf0f9b19497"