HTTP 标头:X-FORWARDED-FOR、X_FORWARDED_FOR 和 HTTP_X_FORWARDED_FOR 有什么区别? [英] HTTP Headers: What is the difference between X-FORWARDED-FOR, X_FORWARDED_FOR and HTTP_X_FORWARDED_FOR?
问题描述
我看到了非 RFCXFF"HTTP 标头的各种拼写,这些标头用于识别转发请求的 IP 地址.这些不同的标头名称之间是否有区别:X-FORWARDED-FOR
、X_FORWARDED_FOR
和 HTTP_X_FORWARDED_FOR
?我需要寻找所有三个吗?
I see various spellings of the non-RFC "XFF" HTTP header used for identifying the IP addresses the request has been forwarded through. Is there a difference between these different header names: X-FORWARDED-FOR
, X_FORWARDED_FOR
, and HTTP_X_FORWARDED_FOR
? Do I need to look for all three?
PS - 是的,我知道这个标题很容易被欺骗:)
PS - Yes, I know this header can be easily spoofed :)
推荐答案
HTTP_ 前缀被 PHP 等一些语言用来区分 HTTP 标头和其他服务器变量:
The HTTP_ prefix is used by some languages like PHP simply to distinguish HTTP headers from other server variables:
$_SERVER['HTTP_X_FORWARDED_FOR']
HTTP头名其实是
X-Forwarded-For
标头名称本身不区分大小写.但是,当您要查询请求标头时,编程语言在很大程度上是区分大小写的(同样,PHP 就是其中之一).
The header name itself is case insensitive. However, when you want to query a request header, programming languages are largely case sensitive about it (again, PHP is one of them).
X- 表示 Forwarded-For 标头是非标准的.我认为语言使用破折号或下划线来引用标题名称没有区别.
The X- indicates that the Forwarded-For header is non-standard. I don't think there's a difference whether a language uses dashes or underscores to refer to header names.
本质上,它们都是相同的标头,只是在不同的实现中引用不同.
Essentially, they're all the same header, just referred to differently by various implementations.
这篇关于HTTP 标头:X-FORWARDED-FOR、X_FORWARDED_FOR 和 HTTP_X_FORWARDED_FOR 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!