Board index » delphi » Indy: Use TIdHTTP with http proxy server in LAN
David
![]() Delphi Developer |
David
![]() Delphi Developer |
Indy: Use TIdHTTP with http proxy server in LAN2003-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? |
Bruce McGee
![]() Delphi Developer |
2003-08-22 08:51:20 PM
Re:Indy: Use TIdHTTP with http proxy server in LAN
David writes:
Quote1/ My computer is in LAN Bruce McGee Glooscap Software |
David
![]() Delphi Developer |
2003-08-26 10:10:31 AM
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! |
Bruce McGee
![]() Delphi Developer |
2003-08-26 07:34:15 PM
Re:Indy: Use TIdHTTP with http proxy server in LAN
David writes:
QuoteThank you Bruce for your response! 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 |
David
![]() Delphi Developer |
2003-08-27 10:06:00 AM
Re:Indy: Use TIdHTTP with http proxy server in LAN
Hi,Bruce:
Thank you for your reponse. 1/ QuoteI haven't used the ProxyConnection before, but I am pretty sure you don't 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; |
Ingvar Nilsen
![]() Delphi Developer |
2003-08-27 03:22:22 PM
Re:Indy: Use TIdHTTP with http proxy server in LAN
David writes:
QuoteSo I tried to use TIdNTLMAuthentication,but failed: 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 |
Ingvar Nilsen
![]() Delphi Developer |
2003-08-27 07:50:15 PM
Re:Indy: Use TIdHTTP with http proxy server in LAN
Bruce McGee writes:
QuoteI haven't used NTLM authentication, but this thread might be useful. may have on Indy and proxy servers will be helpful! -- Ingvar Nilsen |
Bruce McGee
![]() Delphi Developer |
2003-09-02 09:14:51 PM
Re:Indy: Use TIdHTTP with http proxy server in LAN
Ingvar Nilsen writes:
QuoteBruce McGee writes: Bruce McGee Glooscap Software |