From 2647cf14c53a558078e3db9735d5525c345d92cb Mon Sep 17 00:00:00 2001 From: Cazax Date: Thu, 10 Jun 2010 12:35:49 -0400 Subject: [PATCH] Added proxy support for HHTP Clients --- Units/MMLAddon/PSInc/Wrappers/internets.inc | 5 +++++ Units/MMLAddon/PSInc/psexportedmethods.inc | 3 ++- Units/MMLAddon/internets.pas | 22 +++++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Units/MMLAddon/PSInc/Wrappers/internets.inc b/Units/MMLAddon/PSInc/Wrappers/internets.inc index 87aa531..571bf53 100644 --- a/Units/MMLAddon/PSInc/Wrappers/internets.inc +++ b/Units/MMLAddon/PSInc/Wrappers/internets.inc @@ -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; diff --git a/Units/MMLAddon/PSInc/psexportedmethods.inc b/Units/MMLAddon/PSInc/psexportedmethods.inc index b416be5..d687b8e 100644 --- a/Units/MMLAddon/PSInc/psexportedmethods.inc +++ b/Units/MMLAddon/PSInc/psexportedmethods.inc @@ -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 } diff --git a/Units/MMLAddon/internets.pas b/Units/MMLAddon/internets.pas index 9190c44..d947891 100644 --- a/Units/MMLAddon/internets.pas +++ b/Units/MMLAddon/internets.pas @@ -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; @@ -243,5 +262,4 @@ begin inherited Destroy; end; -end. - +end. \ No newline at end of file