Article View: borland.public.cppbuilder.nativeapi
Article #8208Re: How to download a file WITHOUT using the FTP..only through HTTP..
From: Oren Halvani
Date: Mon, 15 Nov 2004 22:56
Date: Mon, 15 Nov 2004 22:56
101 lines
3942 bytes
3942 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb
im Newsbeitrag news:4198ebfe$1@newsgroups.borland.com...
> You didn't read the documentation for those functions, did you? Your
> answers are already answered in the documentation, especially for
> InternetConnect() in particular.
true :-)
I have to confess, that i didn't read *ALL* the details about
those functions :-)
> Change that to this instead:
>
> HINTERNET handle_Connect = InternetConnect(handle_Session,
> "http://www.theserver.com",
> INTERNET_DEFAULT_HTTP_PORT,
> "USER", "PASS",
> INTERNET_SERVICE_HTTP, 0, 0);
Remy, please explain me: why do i need "USER", "PASS"
inside InternetConnect( ) for HTTP ? i thought this is only
needed for FTP, isn't it...?
look below, i've passed now NULL's...
> Just as there are FTP-related functions available, there are also several
> HTTP-related functions available as well. In this case, you need to use
> HttpOpenRequest() and HttpSendRequest() instead of FtpGetFile().
>
>
> Gambit
OK...but WHERE do i have to place:
BOOL HttpSendRequest(
HINTERNET hRequest,
LPCTSTR lpszHeaders,
DWORD dwHeadersLength,
LPVOID lpOptional,
DWORD dwOptionalLength
);
before OR after the HttpOpenRequest( ) ?
by the way, what is this "lpszHeaders" ?
can i pass a NULL here if i just want to
download a file...?
Oren
/*****************************************************/
void __fastcall TfrmMainUnit::Button1Click(TObject *Sender)
{
HINTERNET handle_Session = InternetOpen("My App", 0, 0,
NULL, INTERNET_FLAG_ASYNC);
if(!handle_Session) {ShowMessage("Open Session = failed !"); return;}
HINTERNET handle_Connect = InternetConnect(handle_Session,
"http://www.halvani.de",
INTERNET_DEFAULT_HTTP_PORT,
NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
if(!handle_Connect)
{
InternetCloseHandle(handle_Session); ShowMessage("Connection = failed !");
return;
}
else
{
if(HttpOpenRequest(
handle_Connect,
txtRemoteFile->Text.c_str(),
txtLocalFile->Text.c_str(),
NULL,
NULL,
NULL,
INTERNET_FLAG_RELOAD, /*force to download from origin server, not from
cache*/
0))
{
ShowMessage("Download of File = successfully !");
if(InternetCloseHandle(handle_Session)) ShowMessage("Closing Session =
successfully !");
else ShowMessage("Closing Session = failed !");
}
else
{
ShowMessage("Sorry, couldn't connect..");
if(InternetCloseHandle(handle_Session)) ShowMessage("Closing Session =
successfully !");
else ShowMessage("Closing Session = failed !");
}
}
}
/*****************************************************/
Technical Details
Message-ID:
<4199363d@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<41984e1e@newsgroups.borland.com> <4198ebfe$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f57c5862d590fb6d X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Oren Halvani" <Spam@Me-Please.com> From: "Oren Halvani" <Spam@Me-Please.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <41984e1e@newsgroups.borland.com> <4198ebfe$1@newsgroups.borland.com> Subject: Re: How to download a file WITHOUT using the FTP..only through HTTP.. Date: Mon, 15 Nov 2004 23:56:26 +0100 Lines: 103 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 217.234.92.201 Message-ID: <4199363d@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1100559933 217.234.92.201 (15 Nov 2004 15:05:33 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail