mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-25 18:52:15 -05:00
Added proxy support for HHTP Clients
This commit is contained in:
parent
b48a904c6d
commit
2647cf14c5
@ -51,3 +51,8 @@ function ps_GetRawHeaders(Client: Integer): string; extdecl;
|
|||||||
begin
|
begin
|
||||||
result := CurrThread.MInternet.GetHTTPClient(client).GetRawHeaders;
|
result := CurrThread.MInternet.GetHTTPClient(client).GetRawHeaders;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure ps_SetProxy(Client : Integer; pHost, pPort : String); extdecl;
|
||||||
|
begin
|
||||||
|
CurrThread.MInternet.GetHTTPClient(client).SetProx y(pHost, pPort);
|
||||||
|
end;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
This file is part of the Mufasa Macro Library (MML)
|
This file is part of the Mufasa Macro Library (MML)
|
||||||
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
||||||
|
|
||||||
@ -216,6 +216,7 @@ AddFunction(@ps_PostHTTPPageEx,'function PostHTTPPageEx(Client: Integer;const Ur
|
|||||||
AddFunction(@ps_ClearPostData,'procedure ClearPostData(Client: Integer);');
|
AddFunction(@ps_ClearPostData,'procedure ClearPostData(Client: Integer);');
|
||||||
AddFunction(@ps_AddPostVariable,'procedure AddPostVariable(Client: Integer;const VarName, VarValue: string);');
|
AddFunction(@ps_AddPostVariable,'procedure AddPostVariable(Client: Integer;const VarName, VarValue: string);');
|
||||||
AddFunction(@ps_GetRawHeaders,'function GetRawHeaders(Client: Integer): string;');
|
AddFunction(@ps_GetRawHeaders,'function GetRawHeaders(Client: Integer): string;');
|
||||||
|
AddFunction(@ps_SetProxy,'procedure SetProxy(Client : Integer; pHost, pPort : String);');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{ Color Conversions and Speed }
|
{ Color Conversions and Speed }
|
||||||
|
@ -28,6 +28,7 @@ type
|
|||||||
function GetRawHeaders: string;
|
function GetRawHeaders: string;
|
||||||
procedure ClearPostData;
|
procedure ClearPostData;
|
||||||
procedure AddPostVariable(VarName, VarValue: string);
|
procedure AddPostVariable(VarName, VarValue: string);
|
||||||
|
procedure SetProxy(pHost, pPort : String);
|
||||||
constructor Create(Owner : TObject; HandleCookies : boolean = true);
|
constructor Create(Owner : TObject; HandleCookies : boolean = true);
|
||||||
destructor Destroy;override;
|
destructor Destroy;override;
|
||||||
end;
|
end;
|
||||||
@ -47,6 +48,8 @@ type
|
|||||||
destructor Destroy;override;
|
destructor Destroy;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
ProxyHost, ProxyPort : String;
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -159,6 +162,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
if not fHandleCookies then
|
if not fHandleCookies then
|
||||||
HTTPSend.Cookies.Clear;
|
HTTPSend.Cookies.Clear;
|
||||||
|
if (ProxyHost <> '') and (ProxyPort <> '') then
|
||||||
|
begin
|
||||||
|
HTTPSend.ProxyHost := ProxyHost;
|
||||||
|
HTTPSend.ProxyPort := ProxyPort;
|
||||||
|
end;
|
||||||
HTTPSend.MimeType := 'text/html';
|
HTTPSend.MimeType := 'text/html';
|
||||||
try
|
try
|
||||||
if HTTPSend.HTTPMethod('GET',url) then
|
if HTTPSend.HTTPMethod('GET',url) then
|
||||||
@ -175,6 +183,11 @@ end;
|
|||||||
|
|
||||||
function THTTPClient.PostHTTPPage(Url: string; PostData: string): string;
|
function THTTPClient.PostHTTPPage(Url: string; PostData: string): string;
|
||||||
begin
|
begin
|
||||||
|
if (ProxyHost <> '') and (ProxyPort <> '') then
|
||||||
|
begin
|
||||||
|
HTTPSend.ProxyHost := ProxyHost;
|
||||||
|
HTTPSend.ProxyPort := ProxyPort;
|
||||||
|
end;
|
||||||
HTTPSend.MimeType := 'application/x-www-form-urlencoded';
|
HTTPSend.MimeType := 'application/x-www-form-urlencoded';
|
||||||
HTTPSend.Document.Clear;
|
HTTPSend.Document.Clear;
|
||||||
HTTPSend.Document.Write(Postdata[1],length(postdata));
|
HTTPSend.Document.Write(Postdata[1],length(postdata));
|
||||||
@ -227,6 +240,12 @@ begin
|
|||||||
PostVariables.Add(Varname + '=' + VarValue);
|
PostVariables.Add(Varname + '=' + VarValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure THTTPClient.SetProxy(pHost, pPort : String);
|
||||||
|
begin
|
||||||
|
ProxyHost := pHost;
|
||||||
|
ProxyPort := pPort;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor THTTPClient.Create(Owner : TObject; HandleCookies : boolean = true);
|
constructor THTTPClient.Create(Owner : TObject; HandleCookies : boolean = true);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
@ -244,4 +263,3 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user