AsyncHttpRequest
where uri
is an attributePrints on communication errors and when the remote server returns an HTTP status code not in the 200s.
This class can be instantiated to execute a request where the response is
ignored by the application. Alternatively, it can be subclassed to implement
on_load
.
var request = new SimpleAsyncHttpRequest("http://example.com")
request.start
app :: SimpleAsyncHttpRequest :: uri=
app $ SimpleAsyncHttpRequest :: SELF
Type of this instance, automatically specialized in every classapp $ SimpleAsyncHttpRequest :: uri
URI target of this request, by default it is composed ofuri_root / uri_tail
app :: AsyncHttpRequest :: before
Prepare the UI or other parts of the program before executing the REST requestcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
pthreads :: Thread :: defaultinit
core :: Object :: defaultinit
core :: Finalizable :: defaultinit
app :: AsyncHttpRequest :: defaultinit
app :: AsyncHttpRequest :: delay=
Delay in seconds before sending this requestapp :: AsyncHttpRequest :: deserialize_json
Should the response content be deserialized from JSON?app :: AsyncHttpRequest :: deserialize_json=
Should the response content be deserialized from JSON?core :: Finalizable :: finalize
Liberate any resources held byself
before the memory holding self
is freed
core :: 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.
app :: AsyncHttpRequest :: on_fail
Invoked when the HTTP request has failed and no data was received or deserialization failedcore :: Object :: output_class_name
Display class name on stdout (debug only).app :: AsyncHttpRequest :: uri
URI target of this request, by default it is composed ofuri_root / uri_tail
app :: SimpleAsyncHttpRequest :: uri=
app :: AsyncHttpRequest :: uri_root
Root URI of the remote server, usually the scheme and remote hostapp :: AsyncHttpRequest :: uri_tail
Right part of the URI, afteruri_root
, often the resource path and the query
# Simple `AsyncHttpRequest` where `uri` is an attribute
#
# Prints on communication errors and when the remote server returns an
# HTTP status code not in the 200s.
#
# This class can be instantiated to execute a request where the response is
# ignored by the application. Alternatively, it can be subclassed to implement
# `on_load`.
#
# ~~~nitish
# var request = new SimpleAsyncHttpRequest("http://example.com")
# request.start
# ~~~
class SimpleAsyncHttpRequest
super AsyncHttpRequest
redef var uri
redef fun on_load(data, status) do if status < 200 or status >= 299
then print_error "HTTP request '{uri}' received HTTP status code: {status}"
end
lib/app/http_request.nit:142,1--162,3