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.
    书搞进脑袋 创新 创造; 积极
  • 相关阅读:
    服务端主动关闭 time_wait
    告别Excel!别人家高大上的财务数据分析,这才是老板的最爱
    客户端主动关闭,timed_wait
    两千字揭密 MySQL 8.0.19 三大索引新功能:隐藏索引,降序索引,函数索引
    零基础入门深度学习(3)
    零基础入门深度学习(3)
    零基础入门深度学习(3)
    android 动画学习总结
    android 动画学习总结
    android 动画学习总结
  • 原文地址:https://www.cnblogs.com/tobetterlife/p/12169526.html
Copyright © 2011-2022 走看看