Re: Http Thread Demo

Giganews Newsgroups
Subject: Re: Http Thread Demo
Posted by:  Remy Lebeau (Indy Team) (no.spam@no.spam.com)
Date: Fri, 4 Aug 2006

"indy" <in…@a.com> wrote in message news:5E9BEFD4B002E340in…@a.com...

> Hi all, I've been busting my head trying to find a simple HTTP file
> download demo that uses background threads - preferably with
> resuming... Can anybody help me?

What EXACTLY are you having difficulties with?  Simply instantiate a TIdHTTP
instance in a thread class and then call TIdHTTP.Get() inside the thread's
Execute() method.  As for resuming, you have to set the
TIdHTTP.ProtocolVersion property to pv1_1, and assign the
TIdHTTP.Request.ContentRangeStart/End properties, before then calling Get().
Also, the server has to support HTTP v1.1 and content ranges to begin with.

You did not say which version of Indy you are using.  If you are using the
latest Indy 10 snapshot, then TIdHTTP has an OnHeadersAvailable event that
you can use to verify whether the resuming actually succeeds or not, by
looking for the "Range" header.  If no "Range" header is present, then the
server is sending back the entire file.  To check if the server supports
content ranges ahead of time, you can look for the presence of the
"Accept-Ranges: bytes" header in the response for Head().  The server is not
required to send that header, though, so you could alternatively just issue
the Get() normally and then check its response headers to see if a partial
file is being sent back or not.

Gambit

Replies

None

In response to

Http Thread Demo posted by indy on Fri, 4 Aug 2006