Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Sep : Re: idhttp download file problem with https

www.cryer.info
Managed Newsgroup Archive

Re: idhttp download file problem with https

Subject:Re: idhttp download file problem with https
Posted by:"Axel" (borland.public.delphi.internet.winso..@newsgroups.borland.com)
Date:Fri, 15 Sep 2006 09:33:19

>> I use indi 7 and delphi 7
>
> There is no Indy 7.  Are you using Indy 9 or 10 instead?

Sorry, I use Indy 9


>
>> I try to download a file with https protocol with a function i write
>> down, that works with http protocol.
>
> Try this code:
>
>    function GetWebFile(sUrl, LnomeCompletoOut: String): Boolean;
>    var
>        Strm: TStream;
>        HTTP: TIdHTTP;
>    begin
>        Result := False;
>        try
>            HTTP := TIdHTTP.Create(nil);
>            try
>                with TIdURI.Create(sURL) do
>                try
>                    if AnsiSameText(Protocol, 'https') then
>                        HTTP.IOHandler :=
> TIdSSLIOHandlerSocket.Create(HTTP);
>                finally
>                    Free.
>                end;
>
>                Strm := TFileStream.Create(LnomeCompletoOut, fmCreate);
>                try
>                    HTTP1.Get(sURL, Strm);
>                    Result := True;
>                finally
>                    FreeAndNil(Strm);
>                end;
>            finally
>                FreeAndNil(HTTP);
>            end;
>        except
>        end;
>    end;
>
>> The files downloaded are empty
>
> Then the server is not sending any file data to begin with.
>
>> one time it downloaded a html file of the site
>
> That can happen if your request was invalid/erroneous, such that the
> server
> is sending back an error page without using an HTTP error code.  You need
> to
> look at the response headers to know what the server actually sent before
> you then use the data.
>
>> If i try to savetofile the link in the browser, it start the download
>> with the standard IE download windows.
>
> Is it possible that the server is expecting IE to be the only supported
> browser?  Many servers tailor their content to specific browsers.  By
> default, TIdHTTP does not report itself to be IE.  If you run into this
> kind
> of situation (which happens more often then you might think), you can
> change
> the Request.UserAgent property to mimic IE's UserAgent.
>
>> The indy version is too old??
>
> That is another possibility.
>
>
> Gambit

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive