(转)关于PATH_TRANSLATED的解释
来源:互联网 发布:围棋直播软件 编辑:程序博客网 时间:2024/06/08 11:34
What is PATH_TRANSLATED?
PATH_TRANSLATED is one of the most frequently misunderstood server variables, as this following question illustrates...
Question:
Hi David !
I have some problem with using function SERVER_CONTEXT->GetServerVariable(.......)
all info query i make in HttpFilterProc with SF_NOTIFY_AUTHENTICATION enabled
i need obtain 'PATH_TRANSLATED' server variable. all fork fine if I request some like http://domain.tld/mydir/some_cgi_script.pl
PATH_TRANSLATED - contain full path to this file ('c:/some_site_root/mydir/some_cgi_script.pl') and e.t.c.
but if i request http://domain.tld/mydir/simple.html PATH_TRANSLATED contain just 'c:/some_site_root' - that's all, no 'mydir' in path and no file name.
Why this happens ? or i'm dooing some wrong. maby exists diff. -> request cgi or request html file ?
Answer:
I suspect you are trying to obtain the full physical filename referenced by the virtual URL of the request being authenticated.
Through experimentation, you are guessing that PATH_TRANSLATED is supposed to return the full physical filename to you, but unfortunately, your guess is incorrect. According to CGI 1.1 Specification:
PATH_INFO
The extra path information, as given by the client. In other words, scripts can be accessed by their virtual pathname, followed by extra information at the end of this path. The extra information is sent as PATH_INFO. This information should be decoded by the server if it comes from a URL before it is passed to the CGI script.
PATH_TRANSLATED
The server provides a translated version of PATH_INFO, which takes the path and does any virtual-to-physical mapping to it.
SCRIPT_NAME
A virtual path to the script being executed, used for self-referencing URLs.
As you can see, PATH_TRANSLATED is NOT defined as the "full path to the file" specified by the URL. It is a virtual-to-physical translation of PATH_INFO. And PATH_INFO is the "extra path information" at the end of the CGI script name.
Show me the Annotated Example...
Let me use your examples to illustrate the point. Based on your description, this is your server configuration:
- http://domain.tld/ is a site whose root is mapped to
C:/some_site_root
C:/some_site_root/mydir
is an existing physical directoryC:/some_site_root/mydir/some_cgi_script.pl
andC:/some_site_root/mydir/simple.html
are existing files- .pl extension has an Application Mapping to
C:/cgi-bin/perl.exe
For the following URLs, this is the expected behavior according to CGI 1.1 specification for the server variables PATH_INFO, PATH_TRANSLATED, and SCRIPT_NAME:
Request URLPATH_INFOPATH_TRANSLATEDSCRIPT_NAMEhttp://domain.tld/mydir/some_cgi_script.pl/mydir/some_cgi_script.plC:/some_site_root/mydir/some_cgi_script.pl/mydir/some_cgi_script.plhttp://domain.tld/mydir/simple.html C:/some_site_root/mydir/simple.htmlNotice that since PATH_INFO for the script "/mydir/simple.html" is empty-string, by definition the virtual-to-physical mapping (aka PATH_TRANSLATED) would be for "/" which would be C:/some_site_root. This is the by-design behavior that you observed.
Now, on IIS6, we added a new server variable, SCRIPT_TRANSLATED, which is the virtual-to-physical mapping of SCRIPT_NAME. It is probably what you are looking for. Prior to IIS6, you will have to calculate and generate this yourself, and PATH_TRANSLATED is not it.
- (转)关于PATH_TRANSLATED的解释
- 【转】关于c#中委托的解释
- (转)关于尾递归的解释
- 关于serialVersionUID的解释
- 关于Session的解释
- 关于serialVersionUID的解释
- 关于serialVersionUID的解释
- 关于serialVersionUID的解释
- 关于serialVersionUID的解释
- 关于"^"号的解释
- 关于innerhtml的解释
- 关于serialVersionUID的解释
- 关于Qname的解释
- 关于__iomem的解释
- 关于MET的解释
- 关于剂量的解释
- 关于JBoss 的 解释
- 关于pssm的解释
- json.js原文及使用
- javascript readonly disabled
- 【转】Google 的广告系统
- 关于电脑和传真机连接的问题
- s3c2440学习系列3
- (转)关于PATH_TRANSLATED的解释
- .NET 试试
- 多线程编程(1):线程的启动
- 在internal table中把相邻的两行组织成一行
- Head First C# 中文版 第13章 控件和图形 page605
- JBlend上的Java支持情况(摘自Aplix Corporation Web Site)
- Web.config详解 asp.net优化
- mysql-performance-tools from baoz.net
- 泛型实例