Setting HTTP_X_FORWARDED_FOR server variable in classic ASP

橙三吉。 提交于 2019-12-11 12:42:56

问题


I need to set the HTTP_X_FORWARDED_FOR value in the Request.ServerVariables collection. I'm trying with Fiddler (see this article).

So I set up a custom HTTP request:

GET http://myhost/ HTTP/1.1 http_x_forwarded_for: my.fake.ip.1, my.fake.ip.2 Host: myhost.

The request is correctly executed.

But when I debug the code, the Request.ServerVariables("HTTP_X_FORWARDED_FOR") is empty. Where am I wrong? Is Fiddler the correct tool?


回答1:


The header you are sending should be x-forwarded-for. The Request.ServerVariables are exactly what it says server variables. It does not just contain the http headers sent in the request.

When placing the header values into server variables IIS creates a name for the variable that is based on the header name but is not the name verbatim. It converts all characters to uppercase, replaces all - with _ and adds the prefix of HTTP_ to header name to create a server variable name. The prefix is added to prevent arbitary headers aliasing other fixed server variable names.



来源:https://stackoverflow.com/questions/10224133/setting-http-x-forwarded-for-server-variable-in-classic-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!