🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8192

How to download a file WITHOUT using the FTP..only through HTTP..

#8192
From: Oren Halvani
Date: Mon, 15 Nov 2004 06:34
77 lines
3294 bytes
dear builders,

can someone explain me how to download a file WITHOUT
using the FTP protocol...in our firm we ONLY can access
the 80port HTTP..

so, my question: how can i download a file via:
InternetOpen( ), InternetConnect, InternetOpenFile( ), etc...

the below snip will download a file ONLY via the FTP...

/*****************************************************/
#include <WININET.h>
#include <stdio.h>

void ResponseInfo(char *where)
{
     char lpBuffer[8*1024];
     DWORD Err = GetLastError();
     DWORD Llp = 8*1024;

     if(Err < INTERNET_ERROR_BASE)
     {
        sprintf(lpBuffer, "Standard Windows Error Number %i", Err);
     }
     else
     if(Err == ERROR_INTERNET_EXTENDED_ERROR)
     {
        InternetGetLastResponseInfo( &Err, lpBuffer, &Llp);
     }
     else
     {
        sprintf(lpBuffer,"Standard.Internet.Error.Number.%i",Err);
     };

     MessageBox("..", lpBuffer, where, MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
}

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, "ftp.halvani.de",
                                            INTERNET_DEFAULT_FTP_PORT,
                                            "USER", "PASS",
                                            INTERNET_SERVICE_FTP, 0, 0);
   if(!handle_Connect)
   {
      InternetCloseHandle(handle_Session); ShowMessage("Connection = failed !");
return;
   }
   else
   {
      if(FtpGetFile(handle_Connect, txtRemoteFile->Text.c_str(),
txtLocalFile->Text.c_str(),
           FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_ASCII, 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 !");
      }
   }
/*****************************************************/


Oren
Technical Details
Message-ID: <41984e1e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f57c5862d590fb6d,start
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
Subject: How to download a file WITHOUT using the FTP..only through HTTP..
Date: Mon, 15 Nov 2004 07:34:22 +0100
Lines: 79
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.86.60.181
Message-ID: <41984e1e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1100500510 217.86.60.181 (14 Nov 2004 22:35:10 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail