🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Mike Collins Sun, 23 Jul 2006 13:00
file transfur via http and wininet
#3330
Author: Mike Collins
Date: Sun, 23 Jul 2006 13:00
18 lines
1592 bytes
Hi all, major hair pulling.

Trying to implement a live update facility and have major problems at every 
turn.

Firstly I need to dynamic wininet.dll - which i've posted about previously.

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.

I could really, really do with some helpful pointers on this.

Many, many thanks in advance,

Mike C 
Re: file transfur via http and wininet
#3332
Author: Bob Gonder
Date: Sun, 23 Jul 2006 15:55
56 lines
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, ...)
Re: file transfur via http and wininet
#3185
Author: Mike Collins
Date: Sun, 23 Jul 2006 16:18
89 lines
4631 bytes
Again Bob, thanks for the reply.  It's sunday here so i posted before 
settling back for BBQ.  However, on further reading (couldn't resist) i 
ended up at the same point as you suggested i.e. HttpOpenRequest with the 
GET command.  Not going to test it till tomorrow but i think that will do 
the job.  Also, InternetOpenUrl() looks promising.  It was basically a lack 
in my understanding on how the wininet apis worked and how http operates. 
Now i look at it, it seems very foolish to think that the ftp functions 
would work with an http connection :)

As for Indy, I'm trying to stay clear of any extra VCL's - it's a security 
product that I'm finalising and I'm getting super paranoid - i want to try 
and stay as close to the api's as possible - previous posts will give you a 
better idea.  I've had issues with indy before and the group seems a little 
less active than the nativeapi so i thought i'd just stick to the wininet. 
It's a GINA product and i'm getting some wired result with certain things 
that should normally work but don't.

The server is our own in telehouse - we use it for web hosting as well so 
the administrator is a bit anal.  We've got an sftp service running but he 
didn't want to go down the route of setting an plain ftp server running - 
don't ask me why - these guys are always like that.

Will keep



"Bob Gonder" <notbg@notmindspring.invalid> wrote in message 
news:he07c2hikkr27pbml0ioamg8s0lojmfo7e@4ax.com...
> 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, ...)
>
>
>
> 
Re: file transfur via http and wininet
#3188
Author: Remy Lebeau (TeamB)
Date: Sun, 23 Jul 2006 19:09
16 lines
1284 bytes
"Mike Collins" <its@TheBottomOfThePost.com> wrote in message
news:44c3730e$1@newsgroups.borland.com...

> If i open an Internet connection, via InternetConnect with the
> flag INTERNET_SERVICE_HTTP, is it possible to use the
> ftp related wininet functions

No.  You must use the HTTP functions with that handle.

> or do i have to use the http related ones?

Yes.


Gambit
Re: file transfur via http and wininet
#3189
Author: Remy Lebeau (TeamB)
Date: Sun, 23 Jul 2006 19:11
12 lines
1319 bytes
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message
news:he07c2hikkr27pbml0ioamg8s0lojmfo7e@4ax.com...

> Gambit is going to suggest using Indy 9 instead of rolling
> your own HTTP handler.

Not necessarily.  I have nothing against WinInet.  Since he's already
writing code for WinInet, there is no reason to abandon it.


Gambit
Re: file transfur via http and wininet
#3191
Author: Mike Collins
Date: Sun, 23 Jul 2006 22:04
5 lines
1079 bytes
:-)

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:44c3ca4b$1@newsgroups.borland.com...
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads