首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ISAPI webbroker请求内容字段为空(length = 0)

ISAPI webbroker请求内容字段为空(length = 0)
EN

Stack Overflow用户
提问于 2016-05-22 10:31:26
回答 1查看 420关注 0票数 0

我使用向导创建了一个WebBroker应用程序。我更改了默认操作的代码,如下所示:

代码语言:javascript
复制
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。它没有这个问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-22 14:57:17

经过一些真正深入的谷歌搜索之后,我找到了答案:(虽然Embarcadero文档声明Request.ContentFields包含字段的内容"when MethodType is mtPost",但对于Request.QueryFields的实际无用的文档却没有提到mtGet)。

代码语言:javascript
复制
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;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37373181

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档