app::http_request
using GDK and Curllinux :: http_request $ Text
High-level abstraction for all text representationslinux :: http_request $ Text
High-level abstraction for all text representationsSerializable::inspect
to show more useful information
curl :: native_curl
Binding of C libCurl which allow us to interact with network.serialization :: serialization_core
Abstract services to serialize Nit objects to different formatsdeserialize_json
and JsonDeserializer
serialize_to_json
and JsonSerializer
core :: union_find
union–find algorithm using an efficient disjoint-set data structure
# Implementation of `app::http_request` using GDK and Curl
module http_request
intrude import app::http_request
private import curl
private import gtk::gdk
redef class App
redef fun run_on_ui_thread(task) do gdk_threads_add_idle task
end
redef class Text
redef fun http_get
do
var req = new CurlHTTPRequest(to_s)
var rep = req.execute
if rep isa CurlResponseSuccess then
return new HttpRequestResult(rep.body_str, null, rep.status_code)
else
assert rep isa CurlResponseFailed
var error = new IOError(rep.error_msg)
return new HttpRequestResult(null, error)
end
end
end
lib/linux/http_request.nit:15,1--39,3