Article View: borland.public.cppbuilder.nativeapi
Article #3332Re: file transfur via http and wininet
From: Bob Gonder
Date: Sun, 23 Jul 2006 15:55
Date: Sun, 23 Jul 2006 15:55
56 lines
3094 bytes
3094 bytes
Mike Collins wrote:
>Trying to implement a live update facility and have major problems at every
>turn.
>
>Secondly i need to file transfer via http rather than ftp. The update
>server is http not and ftp server. If i open an Internet connection, via
>InternetConnect with the flag INTERNET_SERVICE_HTTP, is it possible to use
>the ftp related wininet functions i.e. FtpSetCurrentDirectory etc or do i
>have to use the http related ones? If so, any pointers on this.
Gambit is going to suggest using Indy 9 instead of rolling your own
HTTP handler. See recent discussion in b.p.c.internet.socket group
"IdFTP problem". There is an example in that thread of using relative
pathing with Indy's HTTP.
I would suppose
hR = HttpOpenRequest( hConnect, "GET",
"relative/path/update.exe",
NULL,NULL, types,flags,0)
Followed by a loop of
do{
InternetReadFile( hR. Buffer, sizeof(Buffer),
&dwNumberOfBytesRead );
WriteFile( hOut, Buffer, dwNumberOfBytesRead,
&dwNumberOfBytesWritten, NULL );
}while( dwNumberOfBytesRead );
As a suggestion, you might also look into InternetOpenUrl() which
claims to be directly useable by InternetReadFile and
InternetFindNextFile() without needing the InternetConnect().
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetopenurl.asp
The http server is on your ISP?
You can usually FTP to the server. That's how the stuff gets there in
the first place. Just use the ftp address you use to upload the web
pages/files.
Such as in your case, likely
static char ftp[]= "ftp.softwareassociates.com";
But, you would need to supply the name and password for access.
The name and password gets you to your default directory.
From there, I just download the relative path:
FtpGetFile( hFTPSession, "changes.html", "changes.html", ...)
char *from = "updates/update.exe";
char *to = "update.exe.dnld";
ff = FtpFindFirstFile( hFTPSession, from, &FindFrom,
INTERNET_FLAG_RELOAD, NULL );
Then check the file date, and if newer:
FtpGetFile( hFTPSession, from, to, ...)
Technical Details
Message-ID:
<he07c2hikkr27pbml0ioamg8s0lojmfo7e@4ax.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44c3730e$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2bdbfc0e5c446078 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: file transfur via http and wininet Date: Sun, 23 Jul 2006 08:55:41 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <he07c2hikkr27pbml0ioamg8s0lojmfo7e@4ax.com> References: <44c3730e$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 71.49.221.11 X-Trace: newsgroups.borland.com 1153670140 71.49.221.11 (23 Jul 2006 08:55:40 -0700) Lines: 60 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail