Delphi 12.2.1 idhttpserver的利用方法

[复制链接]
发表于 2025-12-16 15:33:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Delphi 12.2.1 idhttpserver的利用方法
1)CommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);变乱
该变乱和IDTCPSERVER的EXECUTE()变乱一样,都是“线程方法”,即变乱是在子线程内里实行的,在其内誊写代码要留意“线程掩护”。
该变乱可以担当客户端HTTP GET、POST或其他HTTP方法哀求。
if SameText(ARequestInfo.Command, 'post') then    // http post方法
else if SameText(ARequestInfo.Command, 'get') then    // http get方法
2)获取URL参数
ARequestInfo.Params.Values['sql']
3)复兴客户端
复兴客户端流
AResponseInfo.ContentStream := LFiredac.QuerySQL(ARequestInfo.Params.Values['sql'], ARequestInfo.Params.Values['storageformat']);  // 流
AResponseInfo.WriteContent;
复兴客户端字符串
AResponseInfo.ContentText := LFiredac.SaveData(ARequestInfo.Params.Values['tablename'], ARequestInfo.PostStream, ARequestInfo.Params.Values['storageformat']);
AResponseInfo.WriteContent;
4)复兴客户端中笔墨符串不乱码
AResponseInfo.ContentText := LFiredac.RestQuery(ARequestInfo.Params.Values['sql']);
AResponseInfo.ContentType := 'text/html; charset=GB2312';
AResponseInfo.WriteContent;
5)PostStream(AContext: TIdContext; AHeaders: TIdHeaderList; var VPostStream: TStream);变乱
假如要担当客户端发过来的流,则在此变乱中要写如下代码:
begin
VPostStream := TMemoryStream.Create; 
end;

回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表