Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Dec : Re: Am i behind a proxy ?
| Subject: | Re: Am i behind a proxy ? |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Mon, 18 Dec 2006 16:27:51 |
"dpap" <dpap@softwaypro.gr> wrote in message
news:45872a9d@newsgroups.borland.com...
> wrote the code bellow to test if user must disturb with proxy's stuff
> or not. i haven't a proxy so i can't test it. You think will work ?
No, it will not work, for the same reason I already explained earlier. You
CANNOT determine the need for a proxy like that. The user MUST tell your
program ahead of time whether or not a proxy is needed. Without the proxy
settings already in place beforehand, TIdHTTP will fail to reach the HTTP
server correctly. TIdHTTP has to be told where the proxy is located, so
that it can connect to the proxy and tell it where to go next. You are
still not doing that yet.
> if Request.UseProxy = ctProxy then // else if there is a proxy
> ask for parametres
That will never work like you intend. The UseProxy property specifies how
the ProxyParams property has been set up before Get() is called. If the
ProxyParams.ProxyServer and ProxyParams.Port have been set, then UseProxy
will be set to ctProxy for HTTP or ctSSLProxy for HTTPS. Otherwise,
UseProxy will be set to ctNormal instead. The UseProxy property is NOT set
to the result of the actual request. It is set to how TIdHTTP is GOING TO
send the request before actually sending it. So you have to set the proxy
settings beforehand.
I do not understand why this is so hard to understand. I will repeat it
again for absolute clearity - there is NO WAY to programmably determine
whether a proxy is needed for any given request. A connection could fail
for ANY number of reasons, NONE of which will report that a proxy is
specifically needed. The user MUST provide that information somewhere,
especially since there are several values involved to begin with (the proxy
IP/port, the username/password and authentication model, the proxy protocol,
etc). Your code can then configure TIdHTTP accordingly before sending
requests afterwards.
Gambit