服务器删除自定义HTTP标头字段

Mar*_*ard 7 php post http http-headers

我一直在尝试接收标头中包含自定义字段的HTTP请求,但似乎我的服务器将其删除...

这是我发送到服务器的请求(我使用HTTP代理读取该请求):

POST /oauth.php/request_token HTTP/1.1
Host: domain.com
User-Agent: DearStranger/1.0 CFNetwork/485.12.7 Darwin/10.6.0
Authorization: OAuth realm="", oauth_consumer_key="ebb942f0d260b06cb533c6133c28408004d343197", oauth_signature_method="HMAC-SHA1", oauth_signature="qPBFAa8XRRbor2%2F%2FQXv6kU3%2F7jU%3D", oauth_timestamp="1295278460", oauth_nonce="E7D6AC76-74CE-4951-8182-7EBF9B382E7E", oauth_version="1.0"
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Pragma: no-cache
Content-Length: 0
Connection: keep-alive
Proxy-Connection: keep-alive
Run Code Online (Sandbox Code Playgroud)

当我到达我的page.php时,我打印了请求的标题.我看到 :

uri http://domain.com/oauth.php/request_token
parameters 
headers Array
.... Accept : */*
.... Accept-Encoding : gzip, deflate
.... Accept-Language : en-us
.... Connection : keep-alive
.... Host : domain.com
.... User-Agent : DearStranger/1.0 CFNetwork/485.12.7 Darwin/10.6.0
method POST
Run Code Online (Sandbox Code Playgroud)

什么时候我应该看到它(它正在本地版本)

uri http://localhost:8888/oauth.php/request_token
parameters 
headers Array
.... Accept : */*
.... Accept-Encoding : gzip, deflate
.... Accept-Language : en-us
.... Authorization : OAuth realm="", oauth_consumer_key="582d95bd45d455fa2e5819f88fc0c5a104d2c7ff3", oauth_signature_method="HMAC-SHA1", oauth_signature="agPSFdtlGxXv2sbrz3pRjHlROOE%3D", oauth_timestamp="1295272680", oauth_nonce="667A133C-5071-48AB-9F13-8146425E46B7", oauth_version="1.0"
.... Connection : keep-alive
.... Content-Length : 0
.... Host : localhost:8888
.... User-Agent : DearStranger/1.0 CFNetwork/485.12.7 Darwin/10.6.0
method POST
Run Code Online (Sandbox Code Playgroud)

我在服务器上使用php 5.2.17.

你有什么想法帮我解决这个问题吗?

谢谢!

Jul*_*ian 8

实际上,有一个非常简单的解决方案.故障来自fastcgi.您只需提供带有重写规则的.htaccess文件即可保存标头.

<IfModule mod_rewrite.c>

...

# Pass Authorization headers to an environment variable
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

</IfModule>
Run Code Online (Sandbox Code Playgroud)

信用点在这里:https://drupal.org/node/1365168

如果您使用的是虚拟主机,他们还会讨论让这些标头通过的更简单的解决方案.


Mar*_*ham 6

Apache剥离Authentication头,因为与CGI一起使用时存在安全风险.你是通过CGI使用PHP吗?

我认为PHP在某些情况下也会剥离身份验证.同样,存在将其暴露给脚本的风险将允许一个用户的代码在同一服务器上嗅探其他用户(例如,如果Alice和Bob都有帐户).