<div dir="ltr"><div>I was having some problems using vanilla sockets and OpenSSL to read a few specific web pages using HTTPS. Normally I don't have any problems using HTTPS, but with a few sites my code was not working. I ending up finding the RTL unit LibCurl in one of the FPC packages and got it working without too much trouble. LibCurl is a library allowing programmers to get the functionality of the curl program without launching an external process.</div><div><br></div><div>If anyone is interested, here is a small bit of code to GET a page over HTTP or HTTPS using LibCurl.</div><div><br></div><div>Interface: </div><div><br></div><div><font face="monospace">function CurlGet(const Url: string; out Data: string; UserAgent: string = ''): Boolean;   </font> <br></div><div><br></div><div>Implementation:</div><div><br></div><font face="monospace">uses<br>  LibCurl;<br><br>function WriteData(Ptr: PChar; MemberSize, MemberCount: UIntPtr; var Data: string): UIntPtr; cdecl;<br>var<br>  S: string;<br>begin<br>  SetString(S, Ptr, MemberSize * MemberCount);<br>  Data := Data + S;<br>  Result := MemberSize * MemberCount;<br>end;<br><br>function CurlGet(const Url: string; out Data: string; UserAgent: string = ''): Boolean;<br>var<br>  Curl: PCURL;<br>begin<br>  Data := '';<br>  Result := False;<br>  if Url = '' then<br>    Exit;<br>  Curl := curl_easy_init();<br>  if Curl = nil then<br>    Exit;<br>  try<br>    curl_easy_setopt(curl, CURLOPT_URL, [PChar(Url)]);<br>    if UserAgent <> '' then<br>      curl_easy_setopt(curl, CURLOPT_USERAGENT, [PChar(UserAgent)]);<br>    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, [@WriteData]);<br>    curl_easy_setopt(curl, CURLOPT_WRITEDATA, [@Data]);<br>    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, [0]);<br>    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, [0]);<br>    Result := curl_easy_perform(curl) = CURLE_OK;<br>  finally<br>    curl_easy_cleanup(Curl);<br>  end;<br>end;</font><br></div>