After lots of help I finnaly have a program wich should work as a proxy.
The problem is, as you may have guessed, it doesnt.
I tried this proxy on my own computer and all I got on my internet explorer is a white screen. After loading another page the proxy reported to have connected but then it hangs itself.
Here is the code:
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. |
The settings i used for the proxy:
port: 80
max connections: 1
keep alive: no
auto start session: no
The settings of internet explorer>extras>options>connection>lan button>
port: 80
ip: 127.0.0.1
The log report of proxy/iexplorer:
proxy:connect
proxy:error
proxy:forwarded
www.google.comproxy:disconnect
iexplorer:blank page (no error just all white)
>>> I load other page/same page again.
proxy:connect
>>> proxy hangs itself and doesnt respond
>>> iexplorer shows error page (site not found bla bla bla please refresh bla bla bla)
i figured the problem is that my proxy sends back a blank package but it does send back something. Another problem could be that the proxy and the iexplorer are on the same comp. I have no idea what causes the error on the second time. i tried changing max connects but nothing changes.
plese help
(also it would be nice if someone could tell me how to post the code in a window.)
thanks
Moderiert von
Tino: Delphi-Tags hinzugefügt