How to download file using TIdHTTP Indy component? - c++builder

I get this error when I try to download a file using TIdHTTP component:
First chance exception at $76D8AAF2. Exception class EIdOSSLUnderlyingCryptoError with message
'Error connecting with SSL.
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'.
Process Project1.exe (3684)
I have Indy version 10.6.2.5341 shipped with Embarcadero Rad Studio 10.1 Berlin.
I'm using IdSSLIOHandlerSocketOpenSSL with those options enabled:
[sslvtlsv1, sslvtlsv1_1, sslvtlsv1_2], but still same error, I also have ssl dlls in my application exe directory (libeay32.dll and ssleay32.dll) version 1.0.2u, got it from this post:
How can we connect with a website? Getting SSL error 1409442E
And this code I use to download a file:
const UnicodeString URL = "https://www.rarlab.com/rar/winrar-x64-60b1.exe";
TMemoryStream *ms = new TMemoryStream();
try
{
IdHTTP1->Get(URL, ms);
ms->SaveToFile("E://winrar.exe");
}
__finally
{
delete ms;
}
Update: I upgraded to Indy version 10.6.2.0 and still have the same SSL problem.

Related

IIS ISAPI error DelphiXE7

Server 2008
IIS 6.0
Delphi XE7
I am getting an error when I read from a stream into a TWICImage on my dll.
Error
Access violation at address 75DB59B5 in module 'ole32.dll'. Read of address 0000000D
WIC:=TWICImage.Create;
Innstream:= TmemoryStream.Create();
Try
// Line below gets a stream from Amazon
ok := ass.GetObject(bucket,folder+'/'+filnavn,Innstream, nil);
Innstream.Position:= 0;
wic.LoadFromStream(Innstream); // This line create the error
from_image.Assign(Wic);
wic.LoadFromStream(Innstream); // This line create the error
If I setup same code in a VCL exe application it works ok , so I guess its my dll missing access to something
any idea ?

NMHTTP component with Delphi causing error

After several years gap I have now started using Delphi 5 again. My project uses the Netmaster NMHTTP component to download a file. It used to work but now I get the following error :-
Your browser sent a request that this server could not understand.
The request line contained invalid characters following the protocol string.
The following code executes a Get using the String urlstext.
urlstext := http://download.finance.yahoo.com/d/updatesec.csv?s= ^NMX0530+^NMX570+^NMX1350' +
'+^NMX1730+^NMX1750+^NMX1770+^NMX2350+^NMX2710+^NMX2720+^NMX2730+^NMX2750+^NMX2770+^NMX2790+' +
'^NMX3350+^NMX3530+^NMX3570+^NMX3720+^NMX3760+^NMX3780+^NMX4530+^NMX4570+^NMX5330+^NMX5370+' +
'^NMX5550+^NMX5750+^NMX6530+^NMX6570+^NMX7530+^NMX7570+^NMX8350+^NMX8530+^NMX8570+^NMX8630+' +
'^NMX8670+^NMX8770+^NMX8980+^NMX9530+^NMX9570&f=snl1c1p2&e=.csv'
NMHTTP1Form := TNMHTTP1Form.Create(Self);
try
NMHTTP1Form.NMHTTP1.Get(urlstext);
except
beep;
nmhttp1form.NMHTTP1.RequestCloseSocket;
nmhttp1form.NMHTTP1.Cancel;
MessageStr := Format('%8s %8s %-s',[DateToStr(Date),TimeToStr(Now),'failure in goonline.download ' + OutputFileName]);
Form1.MessageMemo.Lines.Add(MessageStr);
EventLog(MessageStr);
Result := False;
end;
I discovered a reference through Google that this error means a wrong HTTP version is given HTTP request. I assume this is added by the NMHTTP component (out of sight) so I am wondering how I can correct the situation.
While not strictly a correct answer -
Solution #1
Please consider upgrading to latest Delphi XE6 and use latest Indy.
The problem you have is that NMHTTP (NetMasters HTTP) implements a very old version of HTTP protocol and there is no updates.
If you are still using Delphi 5, please consider using Indy for Delphi 5 instead:
http://www.indyproject.org/download/Files/Indy9.html
Solution #2
NetMasters sells their NM (prefix: Net Masters) components without source-code. Assuming you have the source-code, you can do a hack, such as: change the header from HTTP 1.0 to HTTP 1.1.
If you do not have the source-codes for NetMasters LLC Internet components, you are out of luck. That company is no longer in business.

Connect to excel 2007 file using ADOConnection in Delphi7

I want to connect to an excel 2007 file(.xlsx) using delphi 7, so I used a AdoConnection and set its connectionstring property as:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\qm\Results-summary.xlsx;Extended Properties="Excel 12.0;IMEX=1";Persist Security Info=False
But when I active the AdoConnection i get this error:
Could not find installable ISAM.
Where is the problem?
I found the solution. my mistake was using Microsoft.Jet.OLEDB.4.0 driver for excel 2007 file. I changed it to Microsoft.ACE.OLEDB.12.0 driver and set the extended property to Extended Properties="Excel 12.0 Xml;HDR=yes", now my connection string is:
Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=C:\test\qm\Results-summary.xlsx;Mode=Share Deny None;Extended Properties="Excel 12.0 Xml;HDR=yes";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=37;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False
and it works:)

embedded firebird 2.5 >> DBX Error: Driver could not be properly initialised

i'm try to connect to firebird 2.5 Embedded version(win32) with Delphi XE , I get the error when a click Test Connection
any help?
LibraryName and VendorLib should be in search path
copy LibraryName "i'm using dbx4fb.dll from https://sites.google.com/site/dbxfirebird/home" and
VendorLib "fbclient.dll founded in firebird directory\bin" to the search path "for delphi xe : Program Files\Embarcadero\RAD Studio\8.0\bin"

How to fix 'undeclared identifier' error in Indy?

I have downloaded Indy 10.4587 and I get 'undeclared identifier' error when I try to compile it and install it in Delphi 7.
type
ADDRINFO = record
ai_flags : Integer; // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST
ai_family : Integer; // PF_xxx
ai_socktype : Integer; // SOCK_xxx
ai_protocol : Integer; // 0 or IPPROTO_xxx for IPv4 and IPv6
ai_addrlen : size_t; <---------------------------------------------HERE
...
end;
The error is in this file:
LIB\SYSTEM\IdWship6.pas(49) Fatal: Could not compile used unit 'IdWinsock2.pas'
How can I fix this bug?
Does anybody have the direct download link to a stable version?
It looks like the latest pseudo-stable version of Indy you can download may be 10.4587, which actually may be 10.4.587. There is no ReadMe or About file inside the archive to explain the version and release date. It can be downloaded from a 3rd party web site here: http://indy.fulgan.com
However, people are talking about a possible version 10.5.8. Please let me know if you have a real download link for this 'magic' version.
Edit:
I just downloaded v10.4587 and it doesn't compile.
A quick google on "delphi 7 size_t" offers up a link wherein there is a workaround to define size_t as well as a note that an earlier revision of the indy lib than what you mention is the last one which can be built using delphi 7
see: https://forums.embarcadero.com/thread.jspa?threadID=48622
size_t is an undefined type.
put
size_t = integer;
at the top

Resources