我使用向导创建了一个WebBroker应用程序。我更改了默认操作的代码,如下所示:
procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
i: Integer;
begin
i := Request.ContentLength;
Response.Content :=
'<html>' +
'<head><title>DataSnap Server</title></head>' +
'<body>DataSnap Server x' +
Request.ContentFields.Text + 'x' + IntToStr(i) + 'x' +
'</body>' +
'</html>';
end;我在IIS (6.2-Server 2012)下部署了dll,并使用dll浏览器测试了dll。
http://localhost/MapServer/Mapserver.dll/?param1=hello
只是为了好办法我试过了
http://localhost/MapServer/Mapserver.dll/?param1=“你好”
浏览器输出
DataSnap服务器xx0x
在这两种情况下。
从浏览器发出的调用似乎没有填充Request.ContentFields。
此问题是否特定于Delphi和/或IIS的特定版本?我有什么不明白的?
我试过西雅图和柏林,结果是一样的。谢谢
我还用向导制作了一个独立的WebBroker。它没有这个问题。
发布于 2016-05-22 14:57:17
经过一些真正深入的谷歌搜索之后,我找到了答案:(虽然Embarcadero文档声明Request.ContentFields包含字段的内容"when MethodType is mtPost",但对于Request.QueryFields的实际无用的文档却没有提到mtGet)。
procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
i: Integer;
begin
i := Length(Request.QueryFields.Text);
Response.Content :=
'<html>' +
'<head><title>DataSnap Server</title></head>' +
'<body>DataSnap Server x' +
Request.QueryFields.Text + 'x' + IntToStr(i) + 'x' +
'</body>' +
'</html>';
end;https://stackoverflow.com/questions/37373181
复制相似问题