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;

  • 相关阅读:
    ACCESS中不支持FULL JOIN的解决方案
    C#語法學習異常處理(Exception)
    C#語法學習(索引器[indexer])
    C#語法學習四(Char)
    人生的35个经典好习惯
    自学.NET之路属性,索引器
    Lucene.Net介紹
    Sql Server 日期格式转换
    MS SQL中的交叉数据报表
    C#語法學習一(Array,ArrayList)
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/9929330.html
Copyright © 2011-2022 走看看