Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Aug : http.connect
| Subject: | http.connect |
| Posted by: | "Edmund" (..@kdtc.net) |
| Date: | Wed, 29 Aug 2007 12:43:21 |
Hi,
I finally (Re: Indy 10 installation thread) installed Indy 10 and
am testing out the TIdHttp component along with the TIdSSLIOHandler
SocketOpenSSL component.
I've come across a strange thing.
At the get go, shouldn't the TIdHTTP component have a HOST property?
Isn't the procedure of doing a simple HTTPS client like:
1) Put TIdHTTP and TIdSSLIOHandlerSocketOpenSSL on form.
2) Associate the SSL IOHandler to TIdHttp instance's IOHandler
property.
3) Set host and port in the IOHandler.
4) Execute idHTTP.connect.
5) Get url.
Here's my button_onclick event:
procedure TForm1.Button1Click(Sender: TObject);
var
sURL : string;
begin
idHttp1.IOHandler := idSSLIOHandler;
idSSLIOHandler.Host := 'localhost';
idSSLIOHandler.Port := 443;
idSSLIOHandler.DefaultPort := 443;
idSSLIOHandler.SSLOptions.Method := TIdSSLVersion(sslvSSLv23);
sURL :='https://localhost/';
idHttp1.Connect;
memo1.Text := idHTTP1.Get(sURL);
end;
Once it gets to idHttp1.connect, it throws a "EIdHostRequired
with message ''" error. (I'm not even sure what the message
is.)
Have I done something fundamentally wrong here? As far as I've
read, I need to associate an IOHandler to the idHTTP handler
property, set the IOHandler (in this case IdSSLIOHandler) and
set the handler's host and port properties, and then use
idhttp1.connect to connect to the remote host.
Now I've debugged the IdSSLIOHandler instance and I know
prior to the idHTTP1.connect line, the host name is defined.
Then I step into the connect line (which brings me to the
IdTCPClient source) and once it hits the following line
in the tcpclient source, it throws the Exception.
EIdHostRequired.IfTrue(Host='');
So I stop the app, I enter idhttp1. and wait for the
list of properties/methods available and notice that
the Host property is missing. Please pardon my
ignorance, but since TidHTTP is a descendant of
TIdTCPClient , wouldn't it have a host property?
(Provided it isn't hidden?) Previously
I remembered in Indy9 the TIdHTTP component had the
host and port property.
Can someone point me in the right direction?
Thanks
Edmund