class pipeline :A pipeline is a queue of HTTP calls to performobject..end
pipeline object is a FIFO queue of HTTP calls. It is called
"pipeline" because it is processed asynchronously: Requests may be
sent to the HTTP server independently of whether responses of the
previous requests already arrived or not.
Furthermore, a pipeline object may keep connections to several
servers at once. (More exactly, it has a FIFO queue for every
server it is connected with.)
The pipeline object keeps track what is happening, so you need
not to care about the details of communications. The API is
simple: Create a pipeline object, do some setup (add authentication
methods; configure the proxy to use), add the requests, and
run the pipeline. The rest is done automatically. To get the results,
you can either memorize the requests you wanted to know yourself
and ask every request object about the reply of the server; or
you can specify that a callback function should be called once
the request is processed (with positive or negative result).
It is possible to add further requests to the pipeline from within
these callback functions.
If you want to have several pipelines, or some cooperation with
other network services, you may specify a Unixqueue.event_system.
For example, to have two pipelines working concurrently:
let ues = Unixqueue.create_unix_event_system() in
let p1 = new pipeline in
let p2 = new pipeline in
p1 # set_event_system ues;
p2 # set_event_system ues;
Unixqueue.run ues (* run p1 and p2 in parallel *)
This works not only with pipelines, but with every network client
or server which is compatible with the Unixqueue design.
method set_event_system : Unixqueue.event_system -> unitmethod connection_cache : connection_cachemethod set_connection_cache : connection_cache -> unitmethod add_authentication_method : basic_auth_method -> unitmethod add_auth_handler : auth_handler -> unitmethod set_proxy : string -> int -> unitset_proxy name port:
sets that a proxy name listening on port is to be usedmethod set_proxy_auth : string -> string -> unitmethod avoid_proxy_for : string list -> unit "localhost"; ".our.net" method set_proxy_from_environment : unit -> unithttp_proxy and no_proxy
and set the proxy options from them.method reset : unit -> unitNo_reply (i.e. you get the exception
No_reply if you try to access the response).
If there are callbacks for these requests, the callback
functions are invoked.
The queues of open requests and replies are cleared. All
connections to all servers are inactivated.
Inactivation means that open connections are given back
to the connection cache for further reuse if the state
of the connection allows this; otherwise the connections are
closed.
method add : http_call -> unitmethod add_with_callback : http_call -> (http_call -> unit) -> unit
After the call has been processed, the callback function
is called. This function is called for every call that
leaves the pipeline, it does not matter whether processing
was successful or not. Invoke status on the message
to get what happened; either some status information from the
server is available (perhaps OK status), or an exception is
indicated.
method run : unit -> unithttp_call
object and will be raised once the state of the object is
queried.
Under certain conditions (serious network errors) run does
not catch the exception; it simply cleans its own state up
(aborting the errorneous network connection). In this case,
simply invoke run again to continue.
run terminates normally if the pipeline becomes empty.
The engine handles the following HTTP return codes itself:
method get_options : http_optionsmethod set_options : http_options -> unitmethod number_of_open_messages : intmethod number_of_open_connections : int