Web请求属性“ URL”是空的 [英] Web request property "URL" is empty
问题描述
我试图弄清楚如何从请求( Web.HTTPApp.TWebRequest
)中读取完整 URI。有一个 URL
属性,但是它返回空值,我看不到其他任何可以提供给我的属性。如何获取请求的完整URI?通过Indy 10 TIdHTTPWebBrokerBridge
来使用。
I'm trying to figure out how to read the full URI from a request (Web.HTTPApp.TWebRequest
). There is a URL
property, however it returns empty, and I don't see any more properties which could give me this. How can I get the complete URI of the request? This is being used via Indy 10 TIdHTTPWebBrokerBridge
.
例如...
http://www.mydomain.com:18500/SomePath/SomeFile.html?n=v&a=b
我尝试跟踪此 URL
属性,发现在 IdHTTPWebBrokerBridge中.pas
显然是故意的……
I tried tracking this URL
property and found that in IdHTTPWebBrokerBridge.pas
this is being left blank, apparently deliberately...
function TIdHTTPAppRequest.GetStringVariable(Index: Integer): AnsiString;
...
case Index of
...
//INDEX_URL : Result := AnsiString(FRequestInfo.Document);
INDEX_URL : Result := AnsiString(''); // Root - consistent with ISAPI which return path to root
推荐答案
我不知道为什么 INDEX_URL
返回空字符串。显然,这是故意的。
I don't know why INDEX_URL
returns a blank string. Obviously, it was deliberate, though.
如果您更仔细地查看 IdHTTPWebBrokerBridge.pas
代码,您将看到 INDEX_URL
用于返回 FRequestInfo.Document
,该值与 INDEX_PathInfo
和 INDEX_PathTranslated
都返回。因此,您可以尝试使用 TWebRequest.Host
, TWebRequest.ServerPort
, TWebRequest的组合.Path ...
和 TWebRequest.Query
属性来重新创建您要查找的URL(减去协议,您只需要
If you look at the IdHTTPWebBrokerBridge.pas
code more carefully, you will see that INDEX_URL
used to return FRequestInfo.Document
, which is the same value that INDEX_PathInfo
and INDEX_PathTranslated
both return. So you could try using a combination of the TWebRequest.Host
, TWebRequest.ServerPort
, TWebRequest.Path...
, and TWebRequest.Query
properties to recreate the URL you are looking for (minus the protocol, which you will just have to hard-code).
此外,XE +具有 TWebRequest.RawPathInfo
属性,其中 TIdHTTPAppRequest
实现返回Indy的 TIdHTTPRequestInfo.URI
属性值,因此您也应该查看该值。
Also, XE+ has a TWebRequest.RawPathInfo
property which TIdHTTPAppRequest
implements to return Indy's TIdHTTPRequestInfo.URI
property value, so you should look at that as well.
这篇关于Web请求属性“ URL”是空的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!