Download image with fpHTTPClient lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- lainz · 2020-06-10 15:40 Hi, I know this sound an easy question, but I can download from any other url images except for this one: https://s3.sa-east-1.amazonaws.com/images.posberry.com/26f14ae3-2716- 4501-ba55-93eba5bdaf85-logoweb.png I need to download it and save to file. I'm using this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpClient := TFPHTTPClient.Create(nil);                try                  fpClient.AllowRedirect := True;                  fpClient.AddHeader('User-Agent',LocalPOS.UserAgent);                  fpClient.Get(slParametros.Text, Application.Location + 'file.png');              finally                  fpClient.Free;                end; where UserAgent is like this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'Mozilla/5.0 (Windows; rv:47.0) Gecko/20100101 Firefox/47.0 [POSBerry/1.0.0]' I also have the library for SSL installed (libeay32 and ssleay32) ---------------------------------------------------------------------- balazsszekely · 2020-06-10 16:19 Hi lainz, Your code works fine, even without the SSL libraries, the png is nicely downloaded. Maybe a firewall? ---------------------------------------------------------------------- lainz · 2020-06-10 16:59 Quote from: GetMem on June 10, 2020, 06:19:18 pmHi lainz, Your code works fine, even without the SSL libraries, the png is nicely downloaded. Maybe a firewall? Thanks. I will check my firewall settings. ---------------------------------------------------------------------- rvk · 2020-06-10 17:04 Quote from: GetMem on June 10, 2020, 06:19:18 pmYour code works fine, even without the SSL libraries, the png is nicely downloaded. Even without the SSL libraries? From a https site? That's strange. Are you sure, the ssl libraries from your Windows directory are not taken? Otherwise I would like to know how TFPHTTPClient does this. (Or does TFPHTTPClient use Windows functions which in turn uses the ssl functionally of Windows?) ---------------------------------------------------------------------- balazsszekely · 2020-06-10 17:26 QuoteAre you sure, the ssl libraries from your Windows directory are not taken?I don't have the ssl libraries in the windows directory(just double checked). QuoteOtherwise I would like to know how TFPHTTPClient does this. I don't think it depends on TFPHTTPClient, sometimes the https server will allow the client to download files without the ssl libraries. I think it's a server settings and only works for file download. For example OPM downloads the zip files from: https://packages.lazarus- ide.org/, again no ssl libraries needed. PS: Please note that OPM will warn you if the ssl libraries are missing(third party packages downloaded from github, sourforge, etc.. won't work without the dll's), however you can click no and https://packages.lazarus-ide.org/ still work fine. ---------------------------------------------------------------------- lainz · 2020-06-10 21:27 Strange problem, the solution was to include opensslsockets unit in the uses of the unit that produces the download. But what is more strange is that opensslsockets was already included by other units. This unit must be included in each unit using it? Or I found a bug? The other file that uses opensslsockets is in a separate folder from the project (a subfolder), the path of that folder is added to the project. ---------------------------------------------------------------------- Leledumbo · 2020-06-13 19:18 Quote from: lainz on June 10, 2020, 11:27:47 pmStrange problem, the solution was to include opensslsockets unit in the uses of the unit that produces the download. But what is more strange is that opensslsockets was already included by other units. This unit must be included in each unit using it? Or I found a bug? The other file that uses opensslsockets is in a separate folder from the project (a subfolder), the path of that folder is added to the project. Could it be overridden somehow? The important line from that unit is in the initialization section, which sets the SSL socket handler to a class it defines. Including this unit in the unit that uses it ensures the correct unit loading order.