HTTPSecureSocket does not work for me :-(

i just want to download a file… that’s all
i have created a class called “downloader”. it’s super is HTTPSecureSocket

in the Action event of PushButton1i have this code

dim f as FolderItem = SpecialFolder.Documents.Child("testfile.txt") dim d as new downloader 'd.Yield = true 'd.Secure = true 'd.ConnectionType = SSLSocket.TLSv11 d.Get("https://www.dropbox.com/s/7wvde758ok2rvrh/testfile.txt?dl=0", f)

i have tried to put the file on different server (https://www.dropbox.com), (https://www.filehosting.org) … with no results… all i get is a file with strange information inside

i attach an example project with the file i want to download (“testfile.txt”) and the file i get from the server (“strange_downloaded_file.txt”)

download simple project

FWIW… i use xojo 2016r3, windows 10

You are probably running into HTTP 1.1 and HTTPSecureSocket only does 1.0. You’ll need to upgrade to a version of Xojo that has URLConnection. 2019 R1.1 is good and they did some bug fixes and added some functionality in 2019 R2.

If you can download it via web browser but not the HTTPSocket that’s usually the culprit.

yes bob… i can download it via web browser

This URL leads me to a landing page where I can download the file from this URL:

https://uc3d514db9bfb91c744eabc66c62.dl.dropboxusercontent.com/cd/0/get/Aqd6va-Tg4W36BKeqJn6CEAMN14oBGgdvJcJ_ZM3bc62a3uucRlLoe4ZVniOn_oKTOK-yjvYRAiIX3d_zdiqVEg-m8Qa7xwr_OyMh4MsdglmkFm0BY0m2Jyc--eSTjTVUcc/file?_download_id=0926930212087101504529098581649826458616475720938612262048969319461&_notify_domain=www.dropbox.com&dl=1

Maybe because I’m not logged in to Dropbox?

maybe… i really don’t know

[quote=458487:@BobKeeney]
If you can download it via web browser but not the HTTPSocket that’s usually the culprit.[/quote]
As Bob suggested, use URLConnection. It will follow around redirects as necessary.

so… i can’t download a file with redirects, unless i use xojo 2018r4 or newer?

Redirects are delivered as a status code of 301 or 307 … and you can handle these in a HTTPSecureSocket (but you have to write the code yourself).

But if you need HTTP 1.1 then you really need to use a more modern Xojo.

i just want to download a file from https://www.filehosting.org/
i don’t know if i have to use URLConnection or HTTPSecureSocket or HTTP 1.1
i tried the example project located in xojo 2019r2 examples folder. it uses URLConnection , but no luck…

same problem with xojo example located at C:\Program Files (x86)\Xojo\Xojo 2016r3\Example Projects\Communication\Internet\HTTPDownloader.xojo_binary_project … it uses HTTPSecureSocket … but with no luck either

all i get is a file with this text inside

[code]

301 Moved Permanently

301 Moved Permanently


nginx [/code]

seems like i will need to handle the redirect