zoukankan      html  css  js  c++  java
  • idhttpserver的使用方法

    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;

  • 相关阅读:
    【文章阅读】计算机体系-计算机将代码编译和持续运行过程中需要考虑的问题,以及具体的实现原理讲解
    JAVA性能调试+JProfiler使用相关
    【2016.10.30】王国保卫战-安卓汉化版
    【2017.01.05】装系统教程
    【2016.11.10】百度云离线下载迅雷链接
    mongodb 杂记
    缓存使用思路
    分布式 vs 集群
    切面 aop 笔记
    前端
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/9929330.html
Copyright © 2011-2022 走看看