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;

  • 相关阅读:
    zTree 优秀的jquery树插件
    The underlying provider failed on open 问题解决
    HTML 5 <input> list 属性
    C#拖曳控件加载,bll报错问题
    把VS2010的智能代码提示和注解从英文变成中文
    progressBar的使用
    C++内存读写例子
    bash 管理小脚本
    KVM虚拟机配置笔记
    Ettercap 实施中间人攻击
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/9929330.html
Copyright © 2011-2022 走看看