Board index » delphi » Indy: Use TIdHTTP with http proxy server in LAN

Indy: Use TIdHTTP with http proxy server in LAN


2003-08-22 10:52:59 AM
delphi216
1/ My computer is in LAN
2/ My IE can connect to the internet via HTTP proxy
server:192.9.200.7 on port 80
3/ I have username/password for the server 192.9.200.7.
4/ My idea is to get URL in my delphi code.
5/ I tried TIdHTTP,but I failed:
TIdHTTP.Get(URL)
Always raise an exception: HTTP/1.1 407 Proxy Access Denied
6/ Can I simplely set the four TIdHttp proxy properties:
-server
-port
-username
-password
Will it always work anyway?
Anybody can help me with a short example?
 
 

Re:Indy: Use TIdHTTP with http proxy server in LAN

David writes:
Quote
1/ My computer is in LAN
2/ My IE can connect to the internet via HTTP proxy
server:192.9.200.7 on port 80
3/ I have username/password for the server 192.9.200.7.
4/ My idea is to get URL in my delphi code.
5/ I tried TIdHTTP,but I failed:
TIdHTTP.Get(URL)
Always raise an exception: HTTP/1.1 407 Proxy Access Denied

6/ Can I simplely set the four TIdHttp proxy properties:
-server
-port
-username
-password

Will it always work anyway?

Anybody can help me with a short example?
Are you setting ProxyParams.BasicAuthentication to True?
Regards,
Bruce McGee
Glooscap Software
 

Re:Indy: Use TIdHTTP with http proxy server in LAN

Thank you Bruce for your response!
The Indy version I used is Indy 8,which has no sunch
property--ProxyParams.BasicAuthentication
so I updated my indy to Indy 9.0.14.
The problem still the exists there!
My code is somthing like this:
with IdHTTP1.ProxyParams do
begin
Clear;
BasicAuthentication:=True;
ProxyPassword:='pppp';
ProxyUsername:='uuuu';
ProxyServer:='192.9.200.7';
ProxyPort:=80;
end;
IdHTTP1.Request.ProxyConnection:='Keep-Alive';
IdHTTP1.Host:='www.google.com';
try
IdHTTP1.Get('www.google.com/about.html');
//Here ,I always got:"HTTP/1.1 407 Proxy Access Denied"
Memo1.Lines.Add(IdHTTP1.ResponseText);
except
on E:exception do
begin
Memo1.Lines.Add('Exception:'+E.Message);
end;
end;
Is ther anythinbg wrong with my code?
Thanks again!
 

Re:Indy: Use TIdHTTP with http proxy server in LAN

David writes:
Quote
Thank you Bruce for your response!

The Indy version I used is Indy 8,which has no sunch
property--ProxyParams.BasicAuthentication
so I updated my indy to Indy 9.0.14.

The problem still the exists there!
My code is somthing like this:

with IdHTTP1.ProxyParams do
begin
Clear;
BasicAuthentication:=True;
ProxyPassword:='pppp';
ProxyUsername:='uuuu';
ProxyServer:='192.9.200.7';
ProxyPort:=80;
end;

IdHTTP1.Request.ProxyConnection:='Keep-Alive';
IdHTTP1.Host:='www.google.com';
try
IdHTTP1.Get('www.google.com/about.html');
//Here ,I always got:"HTTP/1.1 407 Proxy Access Denied"
Memo1.Lines.Add(IdHTTP1.ResponseText);
except
on E:exception do
begin
Memo1.Lines.Add('Exception:'+E.Message);
end;
end;

Is ther anythinbg wrong with my code?

Thanks again!
Sorry, I didn't ask which version you were using.
I haven't used the ProxyConnection before, but I am pretty sure you don't
need to set the Host property. Try commenting that line out.
Aside from that, the code seems OK. I use something like this:
HTTP.ProxyParams.ProxyServer := AProxyHost;
HTTP.ProxyParams.ProxyPort := AProxyPort;
HTTP.ProxyParams.ProxyUsername := AProxyUser;
HTTP.ProxyParams.ProxyPassword := AProxyPwd;
if AProxyUser <>'' then
HTTP.ProxyParams.BasicAuthentication := True;
s := HTTP.Get(AURL);
[...]
I hope this helps.
Regards,
Bruce McGee
Glooscap Software
 

Re:Indy: Use TIdHTTP with http proxy server in LAN

Hi,Bruce:
Thank you for your reponse.
1/
Quote
I haven't used the ProxyConnection before, but I am pretty sure you don't
need to set the Host property. Try commenting that line out.
I have deleted the line that set the Host propery, problem still the exists
there!
2/ I have found something after Get method:
IdHTTP1.Get('www.google.com/images/logo.gif');
Now the property: IdHTTP1.Response.ProxyAuthenticate.Text
have a value: Negotiate / NTLM
It seems that the http proxy server needs NTLM Authentication instead of
BasicAuthentication.
So I tried to use TIdNTLMAuthentication,but failed:
My code:
with IdHTTP1.ProxyParams do
begin
Clear;
ProxyPassword:='ppp';
ProxyUsername:='uuu';
ProxyServer:='192.9.200.7';
ProxyPort:=80;
BasicAuthentication := ProxyUsername<>'';
Authentication := TIdNTLMAuthentication.Create; //try NTLM
//I have downloaded libeay32.dll and ssleay32.dll for
TIdNTLMAuthentication
end;
try
IdHTTP1.Get('www.google.com/about.html');
Memo1.Lines.Add(IdHTTP1.ResponseText);
//Result: HTTP/1.1 407 Proxy Access Denied
Memo1.Lines.Add(IdHTTP1.Response.ProxyAuthenticate.Text);
//Reslut: Negotiate/NTLM
except
on E:exception do
begin
Memo1.Lines.Add('Exception:'+E.Message);
end;
end;
 

Re:Indy: Use TIdHTTP with http proxy server in LAN

David writes:
Quote
So I tried to use TIdNTLMAuthentication,but failed:
David, we are struggling with exactly the same problems.
If you wish, we could correspond through e-mail in addition to the news
groups. We can then post the result of our joined efforts to the news
group, for all to enjoy.
My e-mail address is telcontr --- @ --- online.no,
remove the spaces and the ---.
--
Ingvar Nilsen
 

Re:Indy: Use TIdHTTP with http proxy server in LAN

Bruce McGee writes:
Quote
I haven't used NTLM authentication, but this thread might be useful.
Hi Bruce,
I am working on exactly the same, any additional info or links that you
may have on Indy and proxy servers will be helpful!
--
Ingvar Nilsen
 

Re:Indy: Use TIdHTTP with http proxy server in LAN

Ingvar Nilsen writes:
Quote
Bruce McGee writes:

>I haven't used NTLM authentication, but this thread might be useful.

Hi Bruce,

I am working on exactly the same, any additional info or links that you
may have on Indy and proxy servers will be helpful!

I'd be happy to post anything I find when we look at proxies again.
Regards,
Bruce McGee
Glooscap Software