1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Start" href="index.html">
<link rel="previous" href="Http_client.digest_auth_method.html">
<link rel="Up" href="Http_client.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of class types" rel=Appendix href="index_class_types.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Ftp_client" rel="Chapter" href="Ftp_client.html">
<link title="Ftp_data_endpoint" rel="Chapter" href="Ftp_data_endpoint.html">
<link title="Http_client" rel="Chapter" href="Http_client.html">
<link title="Http_client_mt" rel="Chapter" href="Http_client_mt.html">
<link title="Telnet_client" rel="Chapter" href="Telnet_client.html"><title>The Netclient Manual : Http_client.pipeline</title>
</head>
<body>
<div class="navbar"><a href="Http_client.digest_auth_method.html">Previous</a>
<a href="Http_client.html">Up</a>
</div>
<center><h1>Class <a href="type_Http_client.pipeline.html">Http_client.pipeline</a></h1></center>
<br>
<pre><span class="keyword">class</span> <a name="TYPEpipeline"></a>pipeline : <code class="type"></code><code class="code">object</code> <a href="Http_client.pipeline.html">..</a> <code class="code">end</code></pre>A pipeline is a queue of HTTP calls to perform<br>
<hr width="100%">
<a name="2_A"></a>
<h2>A </h2><code class="code">pipeline</code> 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.
<p>
Furthermore, a <code class="code">pipeline</code> object may keep connections to several
servers at once. (More exactly, it has a FIFO queue for every
server it is connected with.)
<p>
The <code class="code">pipeline</code> object keeps track what is happening, so you need
not to care about the details of communications. The API is
simple: Create a <code class="code">pipeline</code> object, do some setup (add authentication
methods; configure the proxy to use), add the requests, and
<code class="code">run</code> 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.
<p>
If you want to have several pipelines, or some cooperation with
other network services, you may specify a <code class="code">Unixqueue.event_system</code>.
For example, to have two pipelines working concurrently:
<p>
<pre><code class="code">
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 *)
</code></pre>
<p>
This works not only with pipelines, but with every network client
or server which is compatible with the <code class="code">Unixqueue</code> design.<pre><span class="keyword">method</span> <a name="METHODset_event_system"></a>set_event_system : <code class="type">Unixqueue.event_system -> unit</code></pre><pre><span class="keyword">method</span> <a name="METHODconnection_cache"></a>connection_cache : <code class="type"><a href="Http_client.html#TYPEconnection_cache">connection_cache</a></code></pre><div class="info">
The current connection cache. By default, a private
restrictive cache is used.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_connection_cache"></a>set_connection_cache : <code class="type"><a href="Http_client.html#TYPEconnection_cache">connection_cache</a> -> unit</code></pre><div class="info">
Set the connection cache. This must happen before the first
call is added.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODadd_authentication_method"></a>add_authentication_method : <code class="type"><a href="Http_client.basic_auth_method.html">basic_auth_method</a> -> unit</code></pre><div class="info">
adds an old-style authentication method<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODadd_auth_handler"></a>add_auth_handler : <code class="type"><a href="Http_client.auth_handler.html">auth_handler</a> -> unit</code></pre><div class="info">
adds a new-style authentication handler<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_proxy"></a>set_proxy : <code class="type">string -> int -> unit</code></pre><div class="info">
<code class="code">set_proxy name port</code>:
sets that a proxy <code class="code">name</code> listening on <code class="code">port</code> is to be used<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_proxy_auth"></a>set_proxy_auth : <code class="type">string -> string -> unit</code></pre><div class="info">
sets user and password for the proxy. Only the "basic"
authentication method is implemented.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODavoid_proxy_for"></a>avoid_proxy_for : <code class="type">string list -> unit</code></pre><div class="info">
sets a list of host names or domain suffixes for which no proxy
should be used.
e.g. <code class="code"> "localhost"; ".our.net" </code><br>
</div>
<pre><span class="keyword">method</span> <a name="METHODset_proxy_from_environment"></a>set_proxy_from_environment : <code class="type">unit -> unit</code></pre><div class="info">
Inspect the environment variables <code class="code">http_proxy</code> and <code class="code">no_proxy</code>
and set the proxy options from them.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODreset"></a>reset : <code class="type">unit -> unit</code></pre><div class="info">
Empties the pipeline and inactivates any open connection.
The currently active operation is interrupted, and every request
with response is set to <code class="code">No_reply</code> (i.e. you get the exception
<code class="code">No_reply</code> 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.
<p>
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.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODadd"></a>add : <code class="type"><a href="Http_client.http_call.html">http_call</a> -> unit</code></pre><div class="info">
Adds the call to the end of the pipeline.
One must not add calls that have already been served.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODadd_with_callback"></a>add_with_callback : <code class="type"><a href="Http_client.http_call.html">http_call</a> -> (<a href="Http_client.http_call.html">http_call</a> -> unit) -> unit</code></pre><div class="info">
Adds the call to the end of the pipeline.
<p>
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 <code class="code">status</code> on the message
to get what happened; either some status information from the
server is available (perhaps OK status), or an exception is
indicated.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODrun"></a>run : <code class="type">unit -> unit</code></pre><div class="info">
Runs through the requests in the pipeline. If a request can be
fulfilled, i.e. the server sends a response, the state of the
request is set and the request is removed from the pipeline.
If a request cannot be fulfilled (no response, bad response,
network error), the exception is stored in the <code class="code">http_call</code>
object and will be raised once the state of the object is
queried.
<p>
Under certain conditions (serious network errors) <code class="code">run</code> does
not catch the exception; it simply cleans its own state up
(aborting the errorneous network connection). In this case,
simply invoke <code class="code">run</code> again to continue.
<code class="code">run</code> terminates normally if the pipeline becomes empty.
<p>
The engine handles the following HTTP return codes itself:<ul>
<li>100: This is an intermediate return code </li>
<li>301: The redirection is followed if configured</li>
<li>302: The redirection is followed if configured</li>
<li>401: Content server authentication</li>
<li>407: Proxy server authentication</li>
</ul>
All other return codes remain uninterpreted, it is up to the
caller of this function to react on them.
<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODget_options"></a>get_options : <code class="type"><a href="Http_client.html#TYPEhttp_options">http_options</a></code></pre><pre><span class="keyword">method</span> <a name="METHODset_options"></a>set_options : <code class="type"><a href="Http_client.html#TYPEhttp_options">http_options</a> -> unit</code></pre><div class="info">
Get/Set the available options for the HTTP engine.
The new options will take into effect immediately.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODnumber_of_open_messages"></a>number_of_open_messages : <code class="type">int</code></pre><div class="info">
Returns the number of messages which are still in the pipeline.<br>
</div>
<pre><span class="keyword">method</span> <a name="METHODnumber_of_open_connections"></a>number_of_open_connections : <code class="type">int</code></pre><div class="info">
Returns the number of connections which are open at the same time
and currently being used by this object (i.e. connections
returned to the cache do not count)<br>
</div>
</body></html>
|