mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-25 10:42:20 -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
|
||||
result := CurrThread.MInternet.GetHTTPClient(client).GetRawHeaders;
|
||||
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)
|
||||
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_AddPostVariable,'procedure AddPostVariable(Client: Integer;const VarName, VarValue: string);');
|
||||
AddFunction(@ps_GetRawHeaders,'function GetRawHeaders(Client: Integer): string;');
|
||||
AddFunction(@ps_SetProxy,'procedure SetProxy(Client : Integer; pHost, pPort : String);');
|
||||
{$ENDIF}
|
||||
|
||||
{ Color Conversions and Speed }
|
||||
|
@ -28,6 +28,7 @@ type
|
||||
function GetRawHeaders: string;
|
||||
procedure ClearPostData;
|
||||
procedure AddPostVariable(VarName, VarValue: string);
|
||||
procedure SetProxy(pHost, pPort : String);
|
||||
constructor Create(Owner : TObject; HandleCookies : boolean = true);
|
||||
destructor Destroy;override;
|
||||
end;
|
||||
@ -47,6 +48,8 @@ type
|
||||
destructor Destroy;override;
|
||||
end;
|
||||
|
||||
var
|
||||
ProxyHost, ProxyPort : String;
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -159,6 +162,11 @@ begin
|
||||
end;
|
||||
if not fHandleCookies then
|
||||
HTTPSend.Cookies.Clear;
|
||||
if (ProxyHost <> '') and (ProxyPort <> '') then
|
||||
begin
|
||||
HTTPSend.ProxyHost := ProxyHost;
|
||||
HTTPSend.ProxyPort := ProxyPort;
|
||||
end;
|
||||
HTTPSend.MimeType := 'text/html';
|
||||
try
|
||||
if HTTPSend.HTTPMethod('GET',url) then
|
||||
@ -175,6 +183,11 @@ end;
|
||||
|
||||
function THTTPClient.PostHTTPPage(Url: string; PostData: string): string;
|
||||
begin
|
||||
if (ProxyHost <> '') and (ProxyPort <> '') then
|
||||
begin
|
||||
HTTPSend.ProxyHost := ProxyHost;
|
||||
HTTPSend.ProxyPort := ProxyPort;
|
||||
end;
|
||||
HTTPSend.MimeType := 'application/x-www-form-urlencoded';
|
||||
HTTPSend.Document.Clear;
|
||||
HTTPSend.Document.Write(Postdata[1],length(postdata));
|
||||
@ -227,6 +240,12 @@ begin
|
||||
PostVariables.Add(Varname + '=' + VarValue);
|
||||
end;
|
||||
|
||||
procedure THTTPClient.SetProxy(pHost, pPort : String);
|
||||
begin
|
||||
ProxyHost := pHost;
|
||||
ProxyPort := pPort;
|
||||
end;
|
||||
|
||||
constructor THTTPClient.Create(Owner : TObject; HandleCookies : boolean = true);
|
||||
begin
|
||||
inherited Create;
|
||||
@ -244,4 +263,3 @@ begin
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user