module http_request




  • http_request: HTTP request services: AsyncHttpRequest and Text::http_get
  • ui: Views and services to use the Android native user interface


  • core: Nit common library of core classes and methods
    • kernel: Most basic classes and methods.
    • text: All the classes and methods related to the manipulation of text entities
      • abstract_text: Abstract class for manipulation of sequences of characters
  • jvm: Java Virtual Machine invocation API and others services from the JNI C API
    • jvm: Java Virtual Machine invocation API and others services from the JNI C API
  • app: app.nit, a framework for portable applications
    • app_base: Base of the app.nit framework, defines App
    • http_request: HTTP request services: AsyncHttpRequest and Text::http_get

from core::kernel


redef class Sys

The main class of the program.

Sys is a singleton class, its only instance is accessible from everywhere with sys.

Because of this, methods that should be accessible from everywhere, like print or exit, are defined in Sys. Moreover, unless there is an ambiguity with self, the receiver of a call to these methods is implicitly sys. Basically it means that the two following instructions are equivalent.

print "Hello World"
sys.print "Hello World"

Methods Implicitly Defined in Sys

Sys is the class where are defined top-level methods, i.e. those defined outside of any class like in a procedural language. Basically it means that

redef class Sys
   fun foo do print "hello"

is equivalent with

fun foo print "hello"

As a corollary, in a top-level method, self (the current receiver) is always sys.

  • print: Force linearization of print

from core::text::abstract_text

from jvm::jvm

from app::app_base

from app::http_request


redef abstract class AsyncHttpRequest

Thread executing an HTTP request asynchronously

The request is sent to uri. Either uri, or uri_root and uri_tail, must be set in subclasses.

If deserialize_json, the default behavior, the response is deserialized from JSON

If delay > 0.0, sending the request is delayed by the given delay in seconds. It can be used to delay resending a request on error.

Four callback methods act on the main/UI thread, they should be implemented as needed in subclasses:

  • before
  • on_load
  • on_fail
  • after

See full example at examples/http_request_example.nit.

  • main: Main method of this thread