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
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
maybe… i really don’t know
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
301 Moved Permanently
301 Moved Permanently
seems like i will need to handle the redirect