[delphi] indy10 idhttpget 방법

2264 단어 Delphiidhttpindy
idhttp에서 get 방법에 대한 정의:
    procedure Get(AURL: string; AResponseContent: TStream); overload;
    procedure Get(AURL: string; AResponseContent: TStream; AIgnoreReplies: array of SmallInt);
     overload;
    function Get(AURL: string): string; overload;
    function Get(AURL: string; AIgnoreReplies: array of SmallInt): string; overload;

그중의 가장 기본적인 방법은 과정류 방법이다
procedure Get(AURL: string; AResponseContent: TStream; AIgnoreReplies: array of SmallInt);
     overload;
다른 get 방법의 재부팅은 모두 끼워 넣은 이 방법에 기반을 두고 있다.
매개변수:
AURL: string;	// get     URL
AResponseContent: TStream;	//    
AIgnoreReplies: array of SmallInt;	//        http      

코드 예:
unit UMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdHTTP, StdCtrls;

type
  TForm1 = class(TForm)
    IdHTTP1: TIdHTTP;
    Memo1: TMemo;
    btnGetOne: TButton;
    btnGetTwo: TButton;
    btnGetThree: TButton;
    btnGetFour: TButton;
    procedure btnGetOneClick(Sender: TObject);
    procedure btnGetTwoClick(Sender: TObject);
    procedure btnGetThreeClick(Sender: TObject);
    procedure btnGetFourClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

const
  Cgeturl = 'http://www.soso.com/';
  C302url = 'http://soso.com/';

var
  RespData : TStringStream;

procedure TForm1.btnGetOneClick(Sender: TObject);
begin
  RespData := TStringStream.Create('');
  IdHTTP1.Get(Cgeturl, RespData);
  Memo1.Text := RespData.DataString;
end;

procedure TForm1.btnGetTwoClick(Sender: TObject);
begin
  RespData := TStringStream.Create('');
  IdHTTP1.Get(C302url, RespData, [302]);
  Memo1.Text := RespData.DataString;
end;

procedure TForm1.btnGetThreeClick(Sender: TObject);
begin
  Memo1.Text := IdHTTP1.Get(Cgeturl);
end;

procedure TForm1.btnGetFourClick(Sender: TObject);
begin
  Memo1.Text := IdHTTP1.Get(C302url, [302]);
end;

end.

데모 다운로드:
http://download.csdn.net/detail/none01/5128838

좋은 웹페이지 즐겨찾기