Native net vs. libcurl

i’m working on a library for connecting 4D to google’s apps. I’ve got things working with native 4D http. After looking over libcurl, I am wondering if it offers any advantages over native http. I don’t see anything that appears to suggest support for asynchronous operations, for example.
I also can’t find much in terms of documentation or examples for libcurl, aside from the demo db that is in the repo.
so why libcurl, and do we have more material on it?

With the new libcul plugin from Myiako, you can for instance get the thermometer on an upload, it will verify the ssl params (4D natives does https, but last time I looked, it does not complain on an expired certificate, or a certificate which is not signed by a CA, etc…)…

I have started a component to make http request with objects using Myiako new plugin.

It looks like this


C_TEXT($vt_url)
$vt_url:="http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"
  //$vt_url:="https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"

C_TEXT($vt_xml)
$vt_xml:=""

C_OBJECT($vo_curlObj)
$vo_curlObj:=CURL_httpObjNew 

ARRAY TEXT($tt_headers;0)
APPEND TO ARRAY($tt_headers;"Accept: application/xml")

C_BLOB($vx_xml)
SET BLOB SIZE($vx_xml;0)

C_LONGINT($vl_error)
$vl_error:=CURL_http_GET ($vt_url;$vo_curlObj;->$vx_xml;->$tt_headers)
If ($vl_error=0)
	If (CURL_httpObjStatusGet ($vo_curlObj)=200)  // $vo_curlObj.status
		
		C_TEXT($vt_contentType)
		$vt_contentType:=CURL_http_headersCollValueGet ($vo_curlObj.response.headers;"content-type")
		
		Case of 
			: ($vt_contentType="text/xml@")
				  //C_TEXT($vt_domRef)
				  //$vt_domRef:=DOM Parse XML source($vx_xml)
				  //If (ok=1)
				  //DOM EXPORT TO VAR($vt_domRef;$vt_xml)
				  //DOM CLOSE XML
				  //End if 
				$vt_xml:=Convert to text($vx_xml;"UTF-8")
				
			: ($vt_contentType="text/html@")
				SET TEXT TO PASTEBOARD(Convert to text($vx_xml;"utf-8"))
				
		End case 
		
	End if 
End if 
  • Why libcurl:

The plugin was originally written for v12, when there were no native HTTP client commands in 4D. For me, a plugin is a stop-gap measure, or an experimental drug, if it works, great, if you can get rid of it, even better.

  • Why no documentation or examples:

I normally write plugins for myself, or for one customer who has paid a fee for me to solve a problem. I might share the code for free, but there is no incentive to promote it or to win more users, the only examples that matter are tests and the only documentation that matters is “note to myself”.

The plugin does use a “multi” API, which is an internal scheduler, a round-robin that runs multiple instances in sequential time slices, not in parallel. For a network client, this makes sense, because normally the speed bottle neck is the network, not processing power. Using more CPU cores doesn’t make the data run faster.

Ah, great. Thanks for the explanations.