1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdTCPServer, IdCmdTCPServer, IdHTTPProxyServer, IdBaseComponent, IdComponent, IdCustomTCPServer, IdCustomHTTPServer, IdHTTPServer, IdContext, IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls;
type TForm1 = class(TForm) Server: TIdHTTPServer; HTTP: TIdHTTP; ListBox1: TListBox; GroupBox1: TGroupBox; Button1: TButton; Edit1: TEdit; Label1: TLabel; Label2: TLabel; Edit2: TEdit; CheckBox1: TCheckBox; CheckBox2: TCheckBox; procedure ServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Button1Click(Sender: TObject); procedure ServerConnect(AContext: TIdContext); procedure ServerDisconnect(AContext: TIdContext); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); var URL, stuff: string; begin URL := 'http://'+ARequestInfo.Host+ARequestInfo.Document; try while HTTP.Tag=1 do Application.ProcessMessages; HTTP.Tag:=1; stuff := HTTP.Get(URL); AResponseInfo.ContentText := stuff; AResponseInfo.ContentType := HTTP.Response.ContentType; HTTP.Tag:=0; application.ProcessMessages; except listbox1.Items.insert(0,'Error'); end; listbox1.Items.Insert(0,URL+' Forwarded'); end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin server.active := false; end;
procedure TForm1.Button1Click(Sender: TObject); begin server.DefaultPort := strtoint(edit1.text); server.maxconnections := strtoint(edit2.text); if checkbox1.Checked = true then server.AutoStartSession := true; if checkbox2.Checked = true then server.KeepAlive := true; edit1.enabled := false; button1.Enabled := false; edit2.Enabled := false; checkbox1.enabled := false; checkbox2.enabled := false; server.Active := true; end;
procedure TForm1.ServerConnect(AContext: TIdContext); begin listbox1.Items.insert(0,'Connected'); end;
procedure TForm1.ServerDisconnect(AContext: TIdContext); begin listbox1.Items.insert(0,'Disconnected'); end;
end. |