$_SERVER['HTTP_REFERER']与Request.ServerVariables("HTTP_REFERER")的区别

3

为什么如果查询字符串包含非英文字符,$_SERVER['HTTP_REFERER'](PHP)和Request.ServerVariables("HTTP_REFERER")(ASP)返回不同的结果?

PHP返回正确的值,但ASP不会:

PHP:сабака

ASP:ׁ׀°׀±׀°׀÷׀°


1
有趣的问题!ASP.NET是直接引用吗?你是如何输出它的? - Pekka
如果您使用网络浏览器进行输出,请查看页面属性中的编码/字符集。 - VolkerK
@Pekka,在 ASP 中使用 response.write,在 PHP 中使用 echo。 - Sasha
@VolkerK,它是同一浏览器,我不相信它会为每种技术(php或asp)发送不同的属性。 - Sasha
@msony 很有可能编码头不同,请检查一下,即使只是为了确认。 - Maerlyn
显示剩余2条评论
1个回答

1
根据RFC 2616,不在ISO-8859-1中的字符应该特别编码。因此,似乎发送头文件的人正在违反规范。请参见field-contentTEXT

4.2消息头

message-header = field-name ":" [ field-value ]
field-name     = token
field-value    = *( field-content | LWS )
field-content  = <the OCTETs making up the field-value
                 and consisting of either *TEXT or combinations
                 of token, separators, and quoted-string>

2.2基本规则

TEXT           = <any OCTET except CTLs,
                 but including LWS>

The TEXT rule is only used for descriptive field contents and values that are not intended to be interpreted by the message parser. Words of *TEXT MAY contain characters from character sets other than ISO- 8859-1 [22] only when encoded according to the rules of RFC 2047 [14].


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接