Q. How to translate following NetTalk code into libcurl?
webclient.SetValue('user', 'mike')
webclient.SetValue('password', '12345')
webclient.SetValue('file', FileName, true)
webclient.Post(url)
A. curl is TCurlHttpClass:
curl.FormAdd('user', 'mike')
curl.FormAdd('password', '12345')
curl.FormAddFile('file', filename)
res = curl.FormPost(url)
Hi!
Thanks for your work!!!
What about updating to current libcurl (7.65.3)?? It has a lot of bugfixes since v7.63.0…
TIA!!
Flavio,
v1.43 is available to download.
WOW!!!
This was FAST!!!
Thank you!!!
Q. How to add HTTP headers? I used
curl.AddHttpHeader(‘x-test: text’)
but those headers never make it to the PHP service.
A. Call curl.SetHttpHeaders() to commit headers added by AddHttpHeader():
curl.AddHttpHeader(‘x-test: text’)
curl.AddHttpHeader(‘y-test: text’)
curl.SetHttpHeaders()
1 Like
Q. a SSL site throws errors when trying to connect.
A1. Don’t verify the authenticity:
curl.SetSSLVerifyPeer(FALSE) !- Don't verify the authenticity of the peer's certificate.
curl.SetSSLVerifyHost(FALSE) !- the connection succeeds regardless of the names in the certificate.
A2. Download the Mozilla CA certificate store PEM file from here and call this:
curl.SetCAInfo('cacert.pem')
curl.SetSSLVerifyPeer(TRUE) !- not necessary, it is default option
curl.SetSSLVerifyHost(TRUE) !- not necessary, it is default option
Thanks to Arnor Baldvinsson for sharing.
1 Like
Hi,
What license is used for this code?
Regards,
Jared
No license is used for this code.
Hi Mike,
I am stuck.
I have setup:
respBuffer &IDynStr
And I use: res = curl.SendRequest(Loc:URL, PostString, respBuffer)
The result I get back is big and it seems to be cutoff before the end of the message.
The start tag I need to get the data from is there but there is no end tag.
The return is a XML file and the section I need is Base64 encoded.
Regards
Johan de Klerk
Johan,
What happens if you call SendRequest to save response to a file?
Hi Mike,
I then get the complete return with the end tags.
Regards
Johan de Klerk
Well, then check dynstr buffer - save its content to a file.
Hi Mike,
Thanks for the suggestion.
I can now save the complete file.
Load it into StringTheory, extract the section I need, Base64Decode it, save it as a ZIP file.
The only problem that I still need to solve is how to get the files extracted from the saved ZIP file.
Regards
Johan de Klerk
Hi Johan,
I just suggested to check dynstr buffer validity.
Hi Mike,
Thanks all sorted.
Works perfect.
LibCurl to the rescue again.
Regards
Johan de Klerk
Q. Is it possible to show a progress bar during the execution of curl.SendRequest?
A. Yes it is possible, you should derive XFerInfo callback method, for example:
curl CLASS(TCurlClass)
XFerInfo PROCEDURE(REAL dltotal, REAL dlnow, REAL ultotal, REAL ulnow), LONG, DERIVED
END
curl.XFerInfo PROCEDURE(REAL dltotal, REAL dlnow, REAL ultotal, REAL ulnow)
CODE
IF dlnow
!- downloaded {dlnow} of {dltotal} bytes
END
IF ulnow
!- uploaded {ulnow} of {ultotal} bytes
END
RETURN PARENT.XFerInfo(dltotal, dlnow, ultotal, ulnow)
4 Likes
Hi Mike,
Will you be updating to LibCurl Ver 7.80.0 - November 10 2021.
Not pushing, your LibCurl is still working 100% for what I use it for in C6.3 and C10.
Just thinking of all the Bug Fixes since 7.65.3 update.
Regards
Johan de Klerk
Hi Johan,
I will update the binaries later today or tomorrow.
1 Like
Hi Mike,
Thank you very much.
You are fast as always.
Regards
Johan de Klerk