<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Ocsigen_messages.html"> <link rel="next" href="Ocsigen_loader.html"> <link rel="Up" href="index.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 modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Ocsigen_cache" rel="Chapter" href="Ocsigen_cache.html"> <link title="Ocsigen_lib_base" rel="Chapter" href="Ocsigen_lib_base.html"> <link title="Ocsigen_lib" rel="Chapter" href="Ocsigen_lib.html"> <link title="Ocsigen_config" rel="Chapter" href="Ocsigen_config.html"> <link title="Ocsigen_getcommandline" rel="Chapter" href="Ocsigen_getcommandline.html"> <link title="Ocsigen_messages" rel="Chapter" href="Ocsigen_messages.html"> <link title="Ocsigen_stream" rel="Chapter" href="Ocsigen_stream.html"> <link title="Ocsigen_loader" rel="Chapter" href="Ocsigen_loader.html"> <link title="Polytables" rel="Chapter" href="Polytables.html"> <link title="Http_headers" rel="Chapter" href="Http_headers.html"> <link title="Ocsigen_http_frame" rel="Chapter" href="Ocsigen_http_frame.html"> <link title="Ocsigen_headers" rel="Chapter" href="Ocsigen_headers.html"> <link title="Framepp" rel="Chapter" href="Framepp.html"> <link title="Ocsigen_http_com" rel="Chapter" href="Ocsigen_http_com.html"> <link title="Ocsigen_charset_mime" rel="Chapter" href="Ocsigen_charset_mime.html"> <link title="Ocsigen_senders" rel="Chapter" href="Ocsigen_senders.html"> <link title="Ocsigen_cookies" rel="Chapter" href="Ocsigen_cookies.html"> <link title="Ocsigen_extensions" rel="Chapter" href="Ocsigen_extensions.html"> <link title="Ocsigen_parseconfig" rel="Chapter" href="Ocsigen_parseconfig.html"> <link title="Ocsigen_http_client" rel="Chapter" href="Ocsigen_http_client.html"> <link title="Ocsigen_local_files" rel="Chapter" href="Ocsigen_local_files.html"> <link title="Ocsigen_server" rel="Chapter" href="Ocsigen_server.html"> <link title="Ocsigen_comet" rel="Chapter" href="Ocsigen_comet.html"> <link title="Accesscontrol" rel="Chapter" href="Accesscontrol.html"> <link title="Authbasic" rel="Chapter" href="Authbasic.html"> <link title="Ocsipersist" rel="Chapter" href="Ocsipersist.html"><title>Ocsigen_stream</title> </head> <body> <div class="navbar"><a class="pre" href="Ocsigen_messages.html" title="Ocsigen_messages">Previous</a> <a class="up" href="index.html" title="Index">Up</a> <a class="post" href="Ocsigen_loader.html" title="Ocsigen_loader">Next</a> </div> <h1>Module <a href="type_Ocsigen_stream.html">Ocsigen_stream</a></h1> <pre><span class="keyword">module</span> Ocsigen_stream: <code class="code">sig</code> <a href="Ocsigen_stream.html">..</a> <code class="code">end</code></pre><div class="info module top"> Streams are a means to read data block by block<br> </div> <hr width="100%"> <pre><span id="EXCEPTIONInterrupted"><span class="keyword">exception</span> Interrupted</span> <span class="keyword">of</span> <code class="type">exn</code></pre> <pre><span id="EXCEPTIONCancelled"><span class="keyword">exception</span> Cancelled</span></pre> <pre><span id="EXCEPTIONAlready_read"><span class="keyword">exception</span> Already_read</span></pre> <pre><span id="EXCEPTIONFinalized"><span class="keyword">exception</span> Finalized</span></pre> <br> Streams are a means to read data block by block<br> <pre><span id="TYPEstream"><span class="keyword">type</span> <code class="type">'a</code> stream</span> </pre> <pre><code><span id="TYPEstep"><span class="keyword">type</span> <code class="type">'a</code> step</span> = private </code></pre><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstep.Finished"><span class="constructor">Finished</span></span> <span class="keyword">of</span> <code class="type">'a <a href="Ocsigen_stream.html#TYPEstream">stream</a> option</code></code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span id="TYPEELTstep.Cont"><span class="constructor">Cont</span></span> <span class="keyword">of</span> <code class="type">'a * 'a <a href="Ocsigen_stream.html#TYPEstream">stream</a></code></code></td> </tr></table> <div class="info "> A stream may be composed by several substreams. Thus a stream is either something that contains the current buffer and a function to retrieve the following data, or a finished stream with possibly another stream following.<br> </div> <pre><span id="TYPEt"><span class="keyword">type</span> <code class="type">'a</code> t</span> </pre> <pre><span id="TYPEoutcome"><span class="keyword">type</span> <code class="type"></code>outcome</span> = <code class="type">[ `Failure | `Success ]</code> </pre> <pre><span id="VALmake"><span class="keyword">val</span> make</span> : <code class="type">?finalize:(<a href="Ocsigen_stream.html#TYPEoutcome">outcome</a> -> unit Lwt.t) -><br> (unit -> 'a <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t) -> 'a <a href="Ocsigen_stream.html#TYPEt">t</a></code></pre><div class="info "> creates a new stream<br> </div> <pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">'a <a href="Ocsigen_stream.html#TYPEt">t</a> -> 'a <a href="Ocsigen_stream.html#TYPEstream">stream</a></code></pre><div class="info "> call this function if you decide to start reading a stream.<br> <b>Raises</b> <code>Already_read</code> if the stream has already been read.<br> </div> <pre><span id="VALnext"><span class="keyword">val</span> next</span> : <code class="type">'a <a href="Ocsigen_stream.html#TYPEstream">stream</a> -> 'a <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t</code></pre><div class="info "> get the next step of a stream. Fails with <code class="code">Interrupted e</code> if reading the thread failed with exception <code class="code">e</code>, and with <code class="code">Cancelled</code> if the thread has been cancelled.<br> </div> <pre><span id="VALempty"><span class="keyword">val</span> empty</span> : <code class="type">(unit -> 'a <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t) option -> 'a <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t</code></pre><div class="info "> creates an empty step. The parameter is the following substream, if any.<br> </div> <pre><span id="VALcont"><span class="keyword">val</span> cont</span> : <code class="type">'a -> (unit -> 'a <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t) -> 'a <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t</code></pre><div class="info "> creates a non empty step.<br> </div> <pre><span id="VALadd_finalizer"><span class="keyword">val</span> add_finalizer</span> : <code class="type">'a <a href="Ocsigen_stream.html#TYPEt">t</a> -> (<a href="Ocsigen_stream.html#TYPEoutcome">outcome</a> -> unit Lwt.t) -> unit</code></pre><div class="info "> Add a finalizer function. In the current version, finalizers must be called manually.<br> </div> <pre><span id="VALfinalize"><span class="keyword">val</span> finalize</span> : <code class="type">'a <a href="Ocsigen_stream.html#TYPEt">t</a> -> <a href="Ocsigen_stream.html#TYPEoutcome">outcome</a> -> unit Lwt.t</code></pre><div class="info "> Finalize the stream. This function must be called explicitely after reading the stream, otherwise finalizers won't be called.<br> </div> <pre><span id="VALcancel"><span class="keyword">val</span> cancel</span> : <code class="type">'a <a href="Ocsigen_stream.html#TYPEt">t</a> -> unit Lwt.t</code></pre><div class="info "> Cancel the stream, i.e. read the stream until the end, without decoding. Further tries to read on the stream will fail with exception <a href="Ocsigen_stream.html#EXCEPTIONCancelled"><code class="code">Ocsigen_stream.Cancelled</code></a><br> </div> <pre><span id="VALconsume"><span class="keyword">val</span> consume</span> : <code class="type">'a <a href="Ocsigen_stream.html#TYPEt">t</a> -> unit Lwt.t</code></pre><div class="info "> Consume without cancelling. Read the stream until the end, without decoding.<br> </div> <pre><span id="EXCEPTIONStream_too_small"><span class="keyword">exception</span> Stream_too_small</span></pre> <div class="info "> possibly with the size of the stream<br> </div> <pre><span id="EXCEPTIONStream_error"><span class="keyword">exception</span> Stream_error</span> <span class="keyword">of</span> <code class="type">string</code></pre> <pre><span id="EXCEPTIONString_too_large"><span class="keyword">exception</span> String_too_large</span></pre> <pre><span id="VALstring_of_stream"><span class="keyword">val</span> string_of_stream</span> : <code class="type">int -> string <a href="Ocsigen_stream.html#TYPEstream">stream</a> -> string Lwt.t</code></pre><div class="info "> Creates a string from a stream. The first argument is the upper limit of the string length<br> </div> <pre><span id="VALenlarge_stream"><span class="keyword">val</span> enlarge_stream</span> : <code class="type">string <a href="Ocsigen_stream.html#TYPEstep">step</a> -> string <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t</code></pre><div class="info "> Read more data in the buffer<br> </div> <pre><span id="VALstream_want"><span class="keyword">val</span> stream_want</span> : <code class="type">string <a href="Ocsigen_stream.html#TYPEstep">step</a> -> int -> string <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t</code></pre><div class="info "> <code class="code">stream_want s len</code> Returns a stream with at least len bytes in the buffer if possible<br> </div> <pre><span id="VALcurrent_buffer"><span class="keyword">val</span> current_buffer</span> : <code class="type">string <a href="Ocsigen_stream.html#TYPEstep">step</a> -> string</code></pre><div class="info "> Returns the value of the current buffer<br> </div> <pre><span id="VALskip"><span class="keyword">val</span> skip</span> : <code class="type">string <a href="Ocsigen_stream.html#TYPEstep">step</a> -> int64 -> string <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t</code></pre><div class="info "> Skips data. Raises <code class="code">Stream_too_small (Some size)</code> if the stream is too small, where <code class="code">size</code> is the size of the stream.<br> </div> <pre><span id="VALsubstream"><span class="keyword">val</span> substream</span> : <code class="type">string -> string <a href="Ocsigen_stream.html#TYPEstep">step</a> -> string <a href="Ocsigen_stream.html#TYPEstep">step</a> Lwt.t</code></pre><div class="info "> Cut the stream at the position given by a string delimiter<br> </div> <pre><span id="VALof_file"><span class="keyword">val</span> of_file</span> : <code class="type">string -> string <a href="Ocsigen_stream.html#TYPEt">t</a></code></pre><div class="info "> returns a stream reading from a file. Do not forget to finalize the stream to close the file.<br> </div> <pre><span id="VALof_string"><span class="keyword">val</span> of_string</span> : <code class="type">string -> string <a href="Ocsigen_stream.html#TYPEt">t</a></code></pre><div class="info "> returns a stream containing a string.<br> </div> <pre><span class="keyword">module</span> <a href="Ocsigen_stream.StringStream.html">StringStream</a>: <code class="code">sig</code> <a href="Ocsigen_stream.StringStream.html">..</a> <code class="code">end</code></pre></body></html>