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?

查看:314
本文介绍了HTTP标头:X-FORWARDED-FOR,X_FORWARDED_FOR和HTTP_X_FORWARDED_FOR有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到非RFCXFFHTTP标头的各种拼写,用于标识请求已转发的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 :)

推荐答案

某些语言(如PHP)使用HTTP_前缀只是为了区分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标头名称实际上是

The HTTP header name is actually

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆