【发布时间】:2017-01-31 12:59:51
【问题描述】:
我有一个由WebBroker REST 制作的项目,作为服务运行,我需要将Cotent-Type 响应更改为application/json,默认情况下WebBroker REST 给我带来了
内容类型'text/html; charset=ISO-8859-1'
我通过访问方法来改变响应
GetInvocationMetadata(True).ResponseContentType = 'application/json'
属于Data.DBXPlatform 类,但它仍然无法解决它,它会在当前类的下方添加另一个Content-Type。
这只发生在WebBroker REST,如果我通过DataSnap Server创建一个项目,我通常会得到它。但我需要WebBroker REST 才能访问客户发送给我的信息。
如何使问题发生的示例。
- 从
DataSnap REST Application创建一个项目
在 ServerMethods 类中,做同样的模型。
uses System.StrUtils, Data.DBXPlatform;
function TServerMethods1.EchoString(Value: string): string;
begin
Result := Value;
GetInvocationMetadata.ResponseContentType := 'application/json';
end;
示例响应标头。
连接:关闭
内容类型:文本/html;字符集=ISO-8859-1
内容长度:25
日期:格林威治标准时间 2013 年 9 月 10 日星期二 16:41:37
编译指示:dssession=542354.126073.592372,dssessionexpires=1200000
内容类型:application/json
【问题讨论】:
标签: json rest delphi indy datasnap