$ _SERVER ['HTTP_REFERER'] vs Request.ServerVariables(“HTTP_REFERER”)

时间:2010-05-31 10:41:38

标签: php asp.net unicode query-string http-referer

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

php返回正确的值,但asp不会:

php:сабака

asp:ׁ|°|±|°|÷|°

1 个答案:

答案 0 :(得分:1)

根据RFC 2616,不应在ISO-8859-1中的字符进行特殊编码。因此,似乎无论谁向你发送标题都违反了规范。请参阅字段内容 TEXT

4.2 Message Headers

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 Basic Rules

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

TEXT规则仅用于描述性字段内容和值   不打算由消息解析器解释。 * TEXT的字只有在根据RFC 2047 [14]的规则编码时才包含ISO-8859-1 [22]以外的字符集中的字符。