Re: idHTTP???

Giganews Newsgroups
Subject: Re: idHTTP???
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Fri, 2 Dec 2005

"Codeman II" <thegentlem…@webmail.co.za> wrote in message
news:53032FE706E4E240thegentlem…@webmail.co.za...

> Can anyone/someone please show me how to do this
> using the idHTTP component of Indy 9.

You already know how because you are already doing it.  You just need to
remove some irrelevent pieces from your existing code.  See below.

> What I had in mind was basically this but I receive an error:
> "Socket error # 11001 Host not found".

That is to be expected for invalid URLs.

> I am not sure what to specify as "Host" property?

You are not supposed to be using the Host property at all.  Pass the full
URL to Get() only.  It will parse the URL and fill in the Host property
internally as needed.

> Do I need to call "Connect()" prior to every "Get"

No.  Get() manages the connection internally as needed.

> or just "Connect" once for all the "Get"s?

Don't call Connect() at all.

> Will idHTTP handle and follows Redirects when I have set
> "HandleRedirects := True" automatically?

Yes.

With that said, try this code:

    Errors := 0;
    memStream := TMemoryStream.Create;
    try
        For X := 0 to UrlList.Count - 1 do
        begin
            try
                memStream.Clear;
                idHTTP.Get(UrlList.Strings[X], memStream);
                memStream.SaveToFile(IntToStr(X) + '.txt');
            except
                Inc(Errors)
            end;
        end;
    finally
        FreeAndNil(memStream);
    end;

Gambit

Replies

In response to

idHTTP??? posted by Codeman II on Fri, 2 Dec 2005