charonn0 / rb-libcurl Goto Github PK
View Code? Open in Web Editor NEWA Realbasic and Xojo binding to libcurl
Home Page: http://www.boredomsoft.org/rb-libcurl.bs
License: MIT License
A Realbasic and Xojo binding to libcurl
Home Page: http://www.boredomsoft.org/rb-libcurl.bs
License: MIT License
Hi,
libcURL works like a charm, but only on one specific URL, we run into a #22 HTTP error.
Our method:
Var curl As New cURLClient
curl.EasyItem.TimeOut = 3
var ascURL as string = "https://graphhopper.com/api/1/"
Var theResult As String
If Not curl.Get(ascURL) Then
via.Log.toConsole("CURL ERROR Position 2: #" + curl.LastError.ToString + " -> https://curl.se/libcurl/c/libcurl-errors.html")
via.Log.toConsole("URL: " + ascURL)
Else
theResult = curl.GetDownloadedData
VIA.Log.toConsole("result received: " + theResult.Length.ToString + "chars long")
VIA.Log.toConsole("http call: successfull")
Return theResult
End If
We always end in the error-section with a #22 cURL error (curl.LastError.ToString).
The page it self is reachable, also when we use cURL on the commandline. Also other calls over the same method (with different URLs) are working as expected.
What is the issue here? What do we miss?
Thanks!!!
The curl_easy_nextheader
function is very new, so if you're not using the bleeding edge latest release of libcurl then it won't be available. The ResponseHeaderEngine
knows this, and falls back on the old behavior if the new API isn't available. However, if the request fails without generating any headers then the ResponseHeaderEngine
will be fooled into thinking the new API is available. When the API is actually called upon a FunctionNotFoundException
is raised.
Setting CookieEngine.Enabled
to False
after previously setting it to True
does not turn off cookies. There doesn't appear to be any obvious way to turn it off; even calling Reset
on the EasyHandle
doesn't do it.
So according to Daniel Stenberg, the way to remove a header is to pass a blank value with the name of the header as you can see here: http://stackoverflow.com/a/26250768
I followed his steps with:
Dim h as new InternetHeaders
h.AppendHeader("X-Requested-With","")
c.SetRequestHeaders(h)
SetRequestHeaders formats it the way it should be ("X-Requested-With:"), but the header doesn't get deleted. Instead it is added multiple times.
I "remove" a header each time I add one, so not sure why it does not work.
Screenshot from Fiddler: http://i.imgur.com/f6OkS0O.png
Let me know if you need a sample project.
The debugger reads computed properties when examining an EasyHandle via Introspection, some of which call into libcURL. This overwrites LastError (often with zero). Store the last error somewhere safe before breaking into the debugger.
Currently, cURLItem detects when a socket is about to be closed in the CloseCallback
method. However, libcURL expects us to actually close the socket from this callback, and we aren't. Thus, the socket enters a Close_Wait
state and does not destruct.
Hi,
we started to use your classes, which work very well.
However we have now the case, that we need to get the response after a POST call. How can that be done?
The .GetDownloadedData
method returns nothing.
Thanks.
In order for a custom subclass of EasyHandle to be copied correctly, the proper subclass constructor must be called from cURLManager.Constructor(cURLManager). Currently, the subclass is detected using IsA
, which is a kludge and doesn't allow anonymous subclasses of EasyHandle to work as expected.
Either cURLManager.Constructor(cURLManager) needs to change, or EasyHandle.Constructor must never be overridden by a subclass.
PUT should run with no errors.
Code run per the example given to PUT ftp file returns "URL using bad/illegal format or missing URL" when build architecture set to ARM 64-bit
Run the demo app with the latest version with build architecture set to X86 64-bit. PUT a file to a server. File transfer is successful.
Close the demo app, change the architecture to ARM 64-bit. PUT the same file to a server and response is "CURLE_URL_MALFORMAT(3): URL using bad/illegal format or missing URL"
Var curl As New cURLClient
Var result As String = ""
Var img As FolderItem = SpecialFolder.CurrentWorkingDirectory.Child("temp.png")
curl.RequestHeaders.SetHeader("X-Api-Key", App.ap1key)
Var data As Dictionary
data.Value("image") = data
If curl.Post(App.ap1_url, data) = True Then
result = curl.GetDownloadedData
End If
TextField3.Text = result
Writing the result in Textfield3
Throwing two errors while compiling:
This item does not exist
bs.write(DEFAULT_CA_INFO_PEM)
Parameter "value" expects type String, but this is type Int32.
bs.write(DEFAULT_CA_INFO_PEM)
Finding liburl.dll
It still complains it doesnt find it tried different versions of the dll
just open in debug of a build version.
If i need more or a specific version could you provide direct links to them ?
Currently, both the simplified cURLClient class and its superclass cURLManager can perform exactly one transfer at a time. This is not a limitation of libcURL. The cURLManager class should permit an arbitrary number of transfers; only the cURLClient class should not since it's meant to be simple to use.
The debugcallback and header callback will be invoked under Linux even though the curl handle has been destroyed. If there were no more instances of cURLItem then cURLItem.Instances will be NIL.
Possibly need a way to track and dispose of FTP data connections.
Even though we're telling libcURL to do so, it's not raising the Progress call back method for some reason.
Possibly also write access.
The file is transferred to the SMB server
A zero byte file is created on the SMB server
While I encounter the problem in my project, I also can't get a PUT working in the cURL.rbvcp sample project. The below steps are using the sample project.
If I enter the path as smb://192.168.1.10/delete-me/file.pdf
and then in the Raw Options enter my username and password, then PUT a pdf file (using either 'Put' or 'Put Threaded') nothing much seems to happen. I do end up with a zero byte file in the SMB share with the name file.pdf
but no data is transferred.
The Xojo debug messages says "Text: Connected to 192.168.1.10 (192.168.1.10) port 445 (#0)"
If I use curl -T file.pdf -u username:password smb://192.168.1.10/delete-me/
then this does transfer the file correctly, so the SMB should be working.
In my application I do get more error messages from libcurl in the debug console - it gives me a "Text: Send failure: Broken pipe" and I also get a zero byte file on the SMB server.
I have tried this on both OSX (libcurl 7.79.1) and on Windows 11 (libcurl 7.83.1) and neither work with SMB.
If using a WebDAV destination rather than SMB everything works as expected.
Any ideas?
This event is raised by the SSLInitCallback method when libcURL is about to create a secure socket. However registering for the callback breaks everything so it's being left alone. See also issue #1
Currently we only ask libcURL for the optimum interval once at the start of the transfer. The interval should be updated during the transfer.
SSL connects, but libcURL complains about the certificate (even if it's valid) and aborts.
Hi, I saw this changelog message:
dc6f1f1
With this, one should be able to append --data-urlencode properties. But we can't find it in the class, was it removed after?
This is the call we try to perform:
curl -X "POST" "[URL]" \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "UserName=[USERNAME]" \
--data-urlencode "Password=[PASSWORD]"
This is our code:
Var theResult As String
Var curl As New cURLClient
curl.EasyItem.TimeOut = timeout
If Not ssl_verifypeer Then
Var sslCertification As Boolean = curl.EasyItem.SetOption(libcURL.Opts.SSL_VERIFYPEER, False)
End If
Call curl.SetRequestMethod("POST")
curl.EasyItem.UseErrorBuffer = True
curl.SetUploadData(requestcontent) 'set the JSON data as a string or memoryblock
curl.RequestHeaders.SetHeader("Content-Type", requesttype) 'set the data type
curl.EasyItem.FollowRedirects = True
If app.useProxy Then
curl.Proxy.Address = app.proxyConfig.Lookup("domain", "").StringValue //"proxy10.domain.loc"
curl.Proxy.Port = app.proxyConfig.Lookup("port", 8080).IntegerValue //8080
curl.Proxy.Type = libcURL.ProxyType.HTTP
End If
Try
If Not curl.Perform(URL, Nil, Nil) Then
//error
Var s As String = libcURL.FormatError(curl.LastError)
// logging here
Else
//success
theResult = curl.GetDownloadedData
End If
Catch err As libcURL.cURLException
// logging here
End Try
Our Post request doesn't follow a redirect.
This is our code:
Call curl.SetRequestMethod("POST") 'set the request method
curl.SetUploadData(requestcontent) 'set the JSON data as a string or memoryblock
curl.RequestHeaders.SetHeader("Content-Type", requesttype) 'set the data type
curl.EasyItem.FollowRedirects = True // !!!!! doesn't work?!
Try
//cURL Call ausführen und ergebnis ermitteln
If Not curl.Perform(URL, Nil, Nil) Then
//error
Var s As String = libcURL.FormatError(curl.LastError)
via.log.toConsole("Curl POST Method Error 1: " + libcURL.FormatError(curl.LastError), True)
Else
//success
theResult = curl.GetDownloadedData
End If
Catch err As libcURL.cURLException
via.log.toConsole("Curl POST Method Error 2: " + libcURL.FormatError(curl.LastError), True)
End Try
//Jobid setzen, wie in dem classic aufruf
Var httpstatus As Integer = curl.GetStatusCode
If httpstatus = 200 OR httpstatus = 201 Then
//message received
via.log.toConsole("Curl POST Method success: " + URL)
Return theResult
Else
//error
// this error is returned
//
via.log.toConsole("Curl POST Method Error 3: " + libcURL.FormatError(curl.LastError), True)
Return ""
End If
The current implementation calls curl_multi_perform
in the Action event of a timer, i.e. on the event loop/main thread. This means that the callback functions will run on the main thread too.
cURLMulti should expose a Perform method which executes curl_multi_perform
once on the calling thread, allowing the caller poll libcurl instead of a timer.
Currently, once an EasyHandle has completed its transfer it is removed from the MultiHandle. This is unnecessary and adds overhead, and may degrade libcURL's ability to re-use connections.
This event is raised by the OpenCallback method when libcURL is about to create a socket. However registering for the callback breaks everything so it's being left alone.
This project has not yet undergone any sort of testing for 64-bit compatibility.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.