zoukankan      html  css  js  c++  java
  • idHttpServer接收类型

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPServer,
      IdCustomHTTPServer, IdHTTPServer;
    
    type
      TForm1 = class(TForm)
        btn1: TButton;
        IdHTTPServer1: TIdHTTPServer;
        mmo1: TMemo;
        procedure btn1Click(Sender: TObject);
        procedure IdHTTPServer1CommandGet(AThread: TIdPeerThread;
          ARequestInfo: TIdHTTPRequestInfo;
          AResponseInfo: TIdHTTPResponseInfo);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.btn1Click(Sender: TObject);
    begin
     try
        IdHTTPServer1.Bindings.Clear;
        //要绑定的端口,一定设置此项,这是真正要绑定的端口;
        IdHTTPServer1.DefaultPort:=8080;
        IdHTTPServer1.Bindings.Add.IP := '192.168.1.100';
        //启动服务器
        IdHTTPServer1.Active := True;
        mmo1.Lines.Add('启动');
      except
         showmessage('启动失败!');
      end;
    
    end;
    
    procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
      ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
    begin
    
      mmo1.Lines.Add(ARequestInfo.Document);
    //  mmo1.Lines.Add(ARequestInfo.QueryParams);
    //  mmo1.Lines.Add(ARequestInfo.Params.Values['Par1'] );
    //  mmo1.Lines.Add(ARequestInfo.Params.Values['Par2'] );
    //  mmo1.Lines.Add(ARequestInfo.Command);
    
      //mmo1.Lines.Add(ARequestInfo.u);
    
      AResponseInfo.ContentType :='text/json';
      AResponseInfo.ContentText:='a:1,b:2';
    
    {  AResponseInfo.ContentEncoding:='utf-8';
        AResponseInfo.ContentType :='text/html';
      AResponseInfo.ContentText:='<html><body>好</body></html>';   }
    
    
    //  AResponseInfo.ContentEncoding:='utf-8';
    //  AResponseInfo.ContentType :='text/html';
    //  AResponseInfo.ContentText:='<html><body>好</body></html>';
    
      //发html文件
       {AResponseInfo.ContentEncoding:='utf-8';
       AResponseInfo.ContentType :='text/html';
       AResponseInfo.ContentText:='<html><body>好</body></html>'; }
       //发xml文件
       {AResponseInfo.ContentType :='text/xml';
       AResponseInfo.ContentText:='<?xml version="1.0" encoding="utf-8"?>'
       +'<students>'
       +'<student sex = "male"><name>'+AnsiToUtf8('陈')+'</name><age>14</age></student>'
       +'<student sex = "female"><name>bb</name><age>16</age></student>'
       +'</students>';}
    
    
    end;
    
    end.
    书搞进脑袋 创新 创造; 积极
  • 相关阅读:
    Jquery消息提示插件toastr使用详解
    spingboot jar 包启动遇到得坑
    freemarker使用shiro标签(spring boot)
    sping boot 集成shiro
    java 线程安全(初级)
    java GC jvm 内存分布 和新生代,老年代,永久代,(详细)
    java的新生代 老年代 永久代
    windows下rabbitmq(架构师必备神器)集群搭建
    友盟移动开发平台.NET版本SDK
    jstree无限级菜单ajax按需动态加载子节点
  • 原文地址:https://www.cnblogs.com/tobetterlife/p/12169526.html
Copyright © 2011-2022 走看看