> On 31/03/2006, at 7:42 AM, Carlo Rubini wrote: > > > I have this particular URL: > > > > http://scripts.sil.org/cms/scripts/render_download.php? > > > site_id=nrsi&format=file&media_id=ukelele_166&filename=Ukele > le_1.6.6.d > > mg > > > > InternetExplorer downloads the file ("Ukelele_1.6.6.dmg") all > > right, while calling httpSock.Get(theAboveUrl) I get error 103 > > > > Any suggestion how to resolve this kind of urls? > > > > Thanks, > > -- > > Carlo
The problem here is that when requesting the URL the server answers with a redirection status code 302 and provides a new URL location to retrieve the file. The new location is: /cms/scripts/render_download.php?site_id=nrsi&format=file&medi a_id=ukelele_166&filename=Ukelele_1.6.6.dmg&_sc=1 The difference is the "&sc_=1" at the end of the URL. IE can handle it automatic for you, but when using an HTTPSocket you must check the httpStatus code on the HTTPSocket's "HeadersReceived" event and if is a 302 code then you must get the "Location" header value and issue a new request to the server. Also when downloading files with HTTPSocket, you can provide a FolderItem in order to store the file: Dim u as String Dim f As FolderItem s = "http://www.domain.com/filetodownload.any f = GetFolderItem("teste.dwg") HTTPSocket1.Get s, f So, for you case you should: 1. Place a HTTPSocket class on the window (Place a TCPSocket control and change its Super to HTTPSocket - change also the name to HTTPSocket1). 2. Place a button on window with this code: Dim s As String // This URL is the new location and downloads the file s = "http://scripts.sil.org/cms/scripts/render_download.php?site_id=nrsi&f ormat=file&media_id=ukelele_166&filename=Ukelele_1.6.6.dmg&_sc=1" Dim f As FolderItem f = GetFolderItem("newfile.dwg") HTTPSocket1.Get s, f 3. To get some feedback about the download progress: 3.1. Place a static text on the window 3.2. Place the following on the HTTPSocket's "ReceiveProgress" event: StaticText1.Text = "Downloading " + _ Format(bytesReceived, "###,###") + _ " of " + Format(totalBytes, "###,###") + " bytes" 3.3. Place the following on the HTTPSocket's "DownloadComplete" event: MsgBox "File downloaded to:" + EndOfLine + file.AbsolutePath 4. Run the project and click the button. If you get an error 103, that means the HTTPSocket cannot reach the server. If you have any Firewall, make sure the Firewall is allowing the application to access the Internet. To see if there's any error when connecting, place a MsgBox on the HTTPSocket's Error event. Tested on a Win2K with RB2005r4 and the file is downloaded with a size of 2,542 KB. Carlos _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
