neo4j :: JsonCurlRequest :: defaultinit
neo4j :: JsonCurlRequest :: execute_hook
Hook to implement in concrete requestsneo4j :: JsonCurlRequest :: init_headers
init HTTP headers for Neo4j REST APIneo4j $ JsonCurlRequest :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
curl :: CurlHTTPRequest :: data=
Data for the body of a POST requestneo4j :: JsonCurlRequest :: defaultinit
curl :: CurlHTTPRequest :: defaultinit
core :: Object :: defaultinit
curl :: CurlRequest :: defaultinit
curl :: CurlHTTPRequest :: delegate
Delegates to customize the behavior when runningexecute
curl :: CurlHTTPRequest :: delegate=
Delegates to customize the behavior when runningexecute
curl :: CurlHTTPRequest :: download_to_file
Download to file given resourceneo4j :: JsonCurlRequest :: execute_hook
Hook to implement in concrete requestscurl :: CurlHTTPRequest :: headers=
Header content of the requestneo4j :: JsonCurlRequest :: init_headers
init HTTP headers for Neo4j REST APIcore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
curl :: CurlHTTPRequest :: method=
The HTTP method, GET by defaultcore :: Object :: output_class_name
Display class name on stdout (debug only).curl :: CurlHTTPRequest :: unix_socket_path
Set the Unix domain socket path to usecurl :: CurlHTTPRequest :: unix_socket_path=
Set the Unix domain socket path to usecurl :: CurlHTTPRequest :: url=
Address of the remote resource to requestcurl :: CurlHTTPRequest :: user_agent
Set the user agent for all following HTTP requestscurl :: CurlHTTPRequest :: user_agent=
Set the user agent for all following HTTP requests
# An abstract request that defines most of the standard options for Neo4j REST API
abstract class JsonCurlRequest
super CurlHTTPRequest
# OAuth token
var auth: nullable String is writable
# init HTTP headers for Neo4j REST API
protected fun init_headers do
headers = new HeaderMap
headers["Accept"] = "application/json; charset=UTF-8"
headers["Transfer-Encoding"] = "chunked"
headers["X-Stream"] = "true"
if auth != null then
headers["Authorization"] = "token {auth.to_s}"
end
# User agent (is used by github to contact devs in case of problems)
if user_agent != null then
headers["User-Agent"] = user_agent.to_s
end
end
redef fun execute do
init_headers
if not self.curl.is_ok then
return answer_failure(0, "Curl instance is not correctly initialized")
end
var success_response = new CurlResponseSuccess
var callback_receiver: CurlCallbacks = success_response
if self.delegate != null then callback_receiver = self.delegate.as(not null)
var err = self.curl.native.easy_setopt(new CURLOption.follow_location, 1)
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
err = self.curl.native.easy_setopt(new CURLOption.http_version, 1)
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
err = self.curl.native.easy_setopt(new CURLOption.url, url)
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
err = self.curl.native.register_callback_header(callback_receiver)
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
err = self.curl.native.register_callback_body(callback_receiver)
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
# HTTP Header
if self.headers != null then
var headers_joined = self.headers.join_pairs(": ")
err = self.curl.native.easy_setopt(
new CURLOption.httpheader, headers_joined.to_curlslist)
if not err.is_ok then return answer_failure(err.to_i, err.to_s)
end
var err_hook = execute_hook
if err_hook != null then return err_hook
var err_resp = perform
if err_resp != null then return err_resp
var st_code = self.curl.native.easy_getinfo_long(new CURLInfoLong.response_code)
if not st_code == null then success_response.status_code = st_code
return success_response
end
# Hook to implement in concrete requests
protected fun execute_hook: nullable CurlResponse do return null
end
lib/neo4j/curl_json.nit:22,1--93,3