Signed-off-by: Matthieu Lucas <lucasmatthieu@gmail.com>
super CurlCallbacks
var curl: Curl
super CurlCallbacks
var curl: Curl
+ var our_body: String = ""
init do self.curl = new Curl
init do self.curl = new Curl
- redef fun body_callback(line: String) do print "Body_callback : {line}"
+ redef fun body_callback(line: String) do self.our_body = "{self.our_body}{line}"
# Stream callback - Cf : No one is registered
redef fun stream_callback(buffer: String, size: Int, count: Int) do print "Stream_callback : {buffer} - {size} - {count}"
# Stream callback - Cf : No one is registered
redef fun stream_callback(buffer: String, size: Int, count: Int) do print "Stream_callback : {buffer} - {size} - {count}"
postContentRequest.verbose = false
var postResponse = postContentRequest.execute
postContentRequest.verbose = false
var postResponse = postContentRequest.execute
+ print "Our body from the callback : {myHttpFetcher.our_body}"
+
if postResponse isa CurlResponseSuccess then
print "*** Answer ***"
print "Status code : {postResponse.status_code}"
if postResponse isa CurlResponseSuccess then
print "*** Answer ***"
print "Status code : {postResponse.status_code}"
-Body_callback : <!doctype html>
+Our body from the callback : <!doctype html>
<html>
<head>
<title>Example Domain</title>
<html>
<head>
<title>Example Domain</title>
+class CallbackManager
+ super CurlCallbacks
+
+ redef fun body_callback(line: String) do end
+end
+
fun error_manager(err: CURLCode) do if not err.is_ok then print err
var url = "http://example.org/"
fun error_manager(err: CURLCode) do if not err.is_ok then print err
var url = "http://example.org/"
#error = curl.easy_setopt(new CURLOption.verbose, 1)
#error_manager(error)
#error = curl.easy_setopt(new CURLOption.verbose, 1)
#error_manager(error)
+var cbManager = new CallbackManager
+error = curl.register_callback(cbManager, new CURLCallbackType.body)
+error_manager(error)
+
error = curl.easy_perform
error_manager(error)
error = curl.easy_perform
error_manager(error)