如果查询字符串包含非英文字符,为什么 $_SERVER['HTTP_REFERER'] (PHP) 和 Request.ServerVariables("HTTP_REFERER") (ASP) 返回不同的结果?
php 返回正确的值但 asp 不会:
php: сабака
asp: ׁ׀°׀±׀°׀÷׀°
最佳答案
根据 RFC 2616 , 不在 ISO-8859-1 中的字符应进行特殊编码。因此,无论是谁向您发送 header ,似乎都违反了规范。请参阅field-content 和TEXT。
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>
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].
关于php - $_SERVER ['HTTP_REFERER' ] 与 Request.ServerVariables ("HTTP_REFERER"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2942958/