<!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="Netcgi_plex.html"> <link rel="next" href="Telnet_client.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 attributes" rel=Appendix href="index_attributes.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="Index of module types" rel=Appendix href="index_module_types.html"> <link title="Uq_gtk" rel="Chapter" href="Uq_gtk.html"> <link title="Equeue" rel="Chapter" href="Equeue.html"> <link title="Unixqueue" rel="Chapter" href="Unixqueue.html"> <link title="Uq_engines" rel="Chapter" href="Uq_engines.html"> <link title="Uq_socks5" rel="Chapter" href="Uq_socks5.html"> <link title="Unixqueue_mt" rel="Chapter" href="Unixqueue_mt.html"> <link title="Equeue_intro" rel="Chapter" href="Equeue_intro.html"> <link title="Uq_ssl" rel="Chapter" href="Uq_ssl.html"> <link title="Uq_tcl" rel="Chapter" href="Uq_tcl.html"> <link title="Netcgi_common" rel="Chapter" href="Netcgi_common.html"> <link title="Netcgi" rel="Chapter" href="Netcgi.html"> <link title="Netcgi_ajp" rel="Chapter" href="Netcgi_ajp.html"> <link title="Netcgi_scgi" rel="Chapter" href="Netcgi_scgi.html"> <link title="Netcgi_cgi" rel="Chapter" href="Netcgi_cgi.html"> <link title="Netcgi_fcgi" rel="Chapter" href="Netcgi_fcgi.html"> <link title="Netcgi_dbi" rel="Chapter" href="Netcgi_dbi.html"> <link title="Netcgi1_compat" rel="Chapter" href="Netcgi1_compat.html"> <link title="Netcgi_test" rel="Chapter" href="Netcgi_test.html"> <link title="Netcgi_porting" rel="Chapter" href="Netcgi_porting.html"> <link title="Netcgi_plex" rel="Chapter" href="Netcgi_plex.html"> <link title="Http_client" rel="Chapter" href="Http_client.html"> <link title="Telnet_client" rel="Chapter" href="Telnet_client.html"> <link title="Ftp_data_endpoint" rel="Chapter" href="Ftp_data_endpoint.html"> <link title="Ftp_client" rel="Chapter" href="Ftp_client.html"> <link title="Nethttpd_types" rel="Chapter" href="Nethttpd_types.html"> <link title="Nethttpd_kernel" rel="Chapter" href="Nethttpd_kernel.html"> <link title="Nethttpd_reactor" rel="Chapter" href="Nethttpd_reactor.html"> <link title="Nethttpd_engine" rel="Chapter" href="Nethttpd_engine.html"> <link title="Nethttpd_services" rel="Chapter" href="Nethttpd_services.html"> <link title="Nethttpd_plex" rel="Chapter" href="Nethttpd_plex.html"> <link title="Nethttpd_intro" rel="Chapter" href="Nethttpd_intro.html"> <link title="Netplex_types" rel="Chapter" href="Netplex_types.html"> <link title="Netplex_mp" rel="Chapter" href="Netplex_mp.html"> <link title="Netplex_mt" rel="Chapter" href="Netplex_mt.html"> <link title="Netplex_log" rel="Chapter" href="Netplex_log.html"> <link title="Netplex_controller" rel="Chapter" href="Netplex_controller.html"> <link title="Netplex_container" rel="Chapter" href="Netplex_container.html"> <link title="Netplex_sockserv" rel="Chapter" href="Netplex_sockserv.html"> <link title="Netplex_workload" rel="Chapter" href="Netplex_workload.html"> <link title="Netplex_main" rel="Chapter" href="Netplex_main.html"> <link title="Netplex_config" rel="Chapter" href="Netplex_config.html"> <link title="Netplex_kit" rel="Chapter" href="Netplex_kit.html"> <link title="Rpc_netplex" rel="Chapter" href="Rpc_netplex.html"> <link title="Netplex_cenv" rel="Chapter" href="Netplex_cenv.html"> <link title="Netplex_intro" rel="Chapter" href="Netplex_intro.html"> <link title="Netshm" rel="Chapter" href="Netshm.html"> <link title="Netshm_data" rel="Chapter" href="Netshm_data.html"> <link title="Netshm_hashtbl" rel="Chapter" href="Netshm_hashtbl.html"> <link title="Netshm_array" rel="Chapter" href="Netshm_array.html"> <link title="Netshm_intro" rel="Chapter" href="Netshm_intro.html"> <link title="Netconversion" rel="Chapter" href="Netconversion.html"> <link title="Netchannels" rel="Chapter" href="Netchannels.html"> <link title="Netstream" rel="Chapter" href="Netstream.html"> <link title="Mimestring" rel="Chapter" href="Mimestring.html"> <link title="Netmime" rel="Chapter" href="Netmime.html"> <link title="Netsendmail" rel="Chapter" href="Netsendmail.html"> <link title="Neturl" rel="Chapter" href="Neturl.html"> <link title="Netaddress" rel="Chapter" href="Netaddress.html"> <link title="Netbuffer" rel="Chapter" href="Netbuffer.html"> <link title="Netdate" rel="Chapter" href="Netdate.html"> <link title="Netencoding" rel="Chapter" href="Netencoding.html"> <link title="Netulex" rel="Chapter" href="Netulex.html"> <link title="Netaccel" rel="Chapter" href="Netaccel.html"> <link title="Netaccel_link" rel="Chapter" href="Netaccel_link.html"> <link title="Nethtml" rel="Chapter" href="Nethtml.html"> <link title="Netstring_str" rel="Chapter" href="Netstring_str.html"> <link title="Netstring_pcre" rel="Chapter" href="Netstring_pcre.html"> <link title="Netstring_mt" rel="Chapter" href="Netstring_mt.html"> <link title="Netmappings" rel="Chapter" href="Netmappings.html"> <link title="Netaux" rel="Chapter" href="Netaux.html"> <link title="Nethttp" rel="Chapter" href="Nethttp.html"> <link title="Netchannels_tut" rel="Chapter" href="Netchannels_tut.html"> <link title="Netmime_tut" rel="Chapter" href="Netmime_tut.html"> <link title="Netsendmail_tut" rel="Chapter" href="Netsendmail_tut.html"> <link title="Netulex_tut" rel="Chapter" href="Netulex_tut.html"> <link title="Neturl_tut" rel="Chapter" href="Neturl_tut.html"> <link title="Netsys" rel="Chapter" href="Netsys.html"> <link title="Netpop" rel="Chapter" href="Netpop.html"> <link title="Rpc_auth_dh" rel="Chapter" href="Rpc_auth_dh.html"> <link title="Rpc_key_service" rel="Chapter" href="Rpc_key_service.html"> <link title="Rpc_time" rel="Chapter" href="Rpc_time.html"> <link title="Rpc_auth_local" rel="Chapter" href="Rpc_auth_local.html"> <link title="Rtypes" rel="Chapter" href="Rtypes.html"> <link title="Xdr" rel="Chapter" href="Xdr.html"> <link title="Rpc" rel="Chapter" href="Rpc.html"> <link title="Rpc_program" rel="Chapter" href="Rpc_program.html"> <link title="Rpc_portmapper_aux" rel="Chapter" href="Rpc_portmapper_aux.html"> <link title="Rpc_packer" rel="Chapter" href="Rpc_packer.html"> <link title="Rpc_transport" rel="Chapter" href="Rpc_transport.html"> <link title="Rpc_client" rel="Chapter" href="Rpc_client.html"> <link title="Rpc_simple_client" rel="Chapter" href="Rpc_simple_client.html"> <link title="Rpc_portmapper_clnt" rel="Chapter" href="Rpc_portmapper_clnt.html"> <link title="Rpc_portmapper" rel="Chapter" href="Rpc_portmapper.html"> <link title="Rpc_server" rel="Chapter" href="Rpc_server.html"> <link title="Rpc_auth_sys" rel="Chapter" href="Rpc_auth_sys.html"> <link title="Rpc_intro" rel="Chapter" href="Rpc_intro.html"> <link title="Rpc_mapping_ref" rel="Chapter" href="Rpc_mapping_ref.html"> <link title="Rpc_ssl" rel="Chapter" href="Rpc_ssl.html"> <link title="Rpc_xti_client" rel="Chapter" href="Rpc_xti_client.html"> <link title="Shell_sys" rel="Chapter" href="Shell_sys.html"> <link title="Shell" rel="Chapter" href="Shell.html"> <link title="Shell_uq" rel="Chapter" href="Shell_uq.html"> <link title="Shell_mt" rel="Chapter" href="Shell_mt.html"> <link title="Shell_intro" rel="Chapter" href="Shell_intro.html"> <link title="Netsmtp" rel="Chapter" href="Netsmtp.html"><link title="Types and Exceptions" rel="Section" href="#1_TypesandExceptions"> <link title="HTTP methods" rel="Section" href="#1_HTTPmethods"> <link title="Authentication" rel="Section" href="#1_Authentication"> <link title="Pipelines" rel="Section" href="#1_Pipelines"> <link title="Convenience module for simple applications" rel="Section" href="#1_Conveniencemoduleforsimpleapplications"> <title>Ocamlnet 2 Reference Manual : Http_client</title> </head> <body> <div class="navbar"><a href="Netcgi_plex.html">Previous</a> <a href="index.html">Up</a> <a href="Telnet_client.html">Next</a> </div> <center><h1>Module <a href="type_Http_client.html">Http_client</a></h1></center> <br> <pre><span class="keyword">module</span> Http_client: <code class="code">sig</code> <a href="Http_client.html">..</a> <code class="code">end</code></pre>HTTP 1.1 client<br> <hr width="100%"> <br> <b>Note for beginners:</b> There is a simplified interface called <a href="Http_client.Convenience.html"><code class="code">Http_client.Convenience</code></a>.<br> <br> Implements much of HTTP/1.1. Implements the following advanced features:<ul> <li>chunked messages</li> <li>persistent connections</li> <li>connections in pipelining mode ("full duplex" connections)</li> <li>modular authentication methods, currently Basic and Digest</li> <li>event-driven implementation; allows concurrent service for several network connections </li> </ul> Left out:<ul> <li>multipart messages, including multipart/byterange</li> <li>content encoding (compression) (1)</li> <li>content digests specified by RFC 2068 and 2069 (1)</li> <li>content negotiation (1)</li> <li>conditional and partial GET (1)</li> <li>following code 303 redirections automatically (1)</li> <li>client-side caching (1)</li> <li>HTTP/0.9 compatibility</li> </ul> (1) These features can be implemented on top of this module if really needed, but there is no special support for them.<br> <br> <b>Thread safety</b> <p> The module can be compiled such that it is thread-safe. In particular, one has to link the http_client_mt.cm<code class="code">xo</code> object, and thread-safety is restricted to the following kinds of usage:<ul> <li>The golden rule is that threads must not share pipeline objects. If every thread uses its own pipeline, every thread will have its own set of state variables. It is not detected if two threads errornously share a pipeline, neither by an error message nor by implicit serialization. Strange things may happen.</li> <li>The same applies to the other objects, e.g. http_call objects</li> <li>The <code class="code">Convenience</code> module even serializes; see below.</li> </ul> <br> <br> <a name="1_TypesandExceptions"></a> <h1>Types and Exceptions</h1><br> <pre><span class="keyword">exception</span> <a name="EXCEPTIONBad_message"></a>Bad_message <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> The server sent a message which cannot be interpreted. The string indicates the reason.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONNo_reply"></a>No_reply</pre> <div class="info"> There was no response to the request because some other request failed earlier and it was not allowed to send the request again.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONToo_many_redirections"></a>Too_many_redirections</pre> <div class="info"> While following redirections the limit has been reached<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONName_resolution_error"></a>Name_resolution_error <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> Could not resolve this name<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONURL_syntax_error"></a>URL_syntax_error <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> This URL cannot be parsed after a redirection has been followed.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONHttp_protocol"></a>Http_protocol <span class="keyword">of</span> <code class="type">exn</code></pre> <div class="info"> The request could not be processed because the exception condition was raised. The inner exception is one of the above defined.<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONHttp_error"></a>Http_error <span class="keyword">of</span> <code class="type">(int * string)</code></pre> <div class="info"> <b>Deprecated.</b> The server sent an error message. The left component of the pair is the error code, the right component is the error text. This exception is only used by <code class="code">get_resp_body</code>.<br> </div> <pre><span class="keyword">type</span> <a name="TYPEstatus"></a><code class="type"></code>status = <code class="type">[ `Client_error<br> | `Http_protocol_error of exn<br> | `Redirection<br> | `Server_error<br> | `Successful<br> | `Unserved ]</code> </pre> <div class="info"> Condensed status information of a HTTP call:<ul> <li><code class="code">`Unserved</code>: The call has not yet been finished</li> <li><code class="code">`HTTP_protocol_error e</code>: An error on HTTP level occurred. Corresponds to the exception <code class="code">Http_protocol</code>.</li> <li><code class="code">`Successful</code>: The call is successful, and the response code is between 200 and 299.</li> <li><code class="code">`Redirection</code>: The call is successful, and the response code is between 300 and 399.</li> <li><code class="code">`Client_error</code>: The call failed with a response code between 400 and 499.</li> <li><code class="code">`Server_error</code>: The call failed for any other reason.</li> </ul> <br> </div> <br><code><span class="keyword">type</span> <a name="TYPEhow_to_reconnect"></a><code class="type">'a</code> how_to_reconnect = </code><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Send_again</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Send the request automatically again</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Request_fails</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Drop the request</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Inquire</span> <span class="keyword">of</span> <code class="type">('a -> bool)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >If the function return <code class="code">true</code> send again, otherwise drop the request.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Send_again_if_idem</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Default behaviour: <code class="code">Send_again</code> for idempotent methods (GET, HEAD), <code class="code">Request_fails</code> for the rest</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <div class="info"> How to deal with automatic reconnections, especially when the connection crashes.<br> </div> <br><code><span class="keyword">type</span> <a name="TYPEhow_to_redirect"></a><code class="type">'a</code> how_to_redirect = </code><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Redirect</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Perform the redirection</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Do_not_redirect</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >No redirection</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Redirect_inquire</span> <span class="keyword">of</span> <code class="type">('a -> bool)</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >If the function return <code class="code">true</code> redirect, otherwise do not redirect. It is legal to set the <code class="code">Location</code> header as part of the action performed by the function. (Should be an absolute http URL.)</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Redirect_if_idem</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Default behaviour: <code class="code">Redirect</code> for idempotent methods (GET, HEAD), <code class="code">Do_not_redirect</code> for the rest</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <pre><span class="keyword">type</span> <a name="TYPEprivate_api"></a><code class="type"></code>private_api </pre> <div class="info"> The private part of the <code class="code">http_call</code> class type<br> </div> <pre><span class="keyword">type</span> <a name="TYPEresponse_body_storage"></a><code class="type"></code>response_body_storage = <code class="type">[ `Body of unit -> <a href="Netmime.mime_body.html">Netmime.mime_body</a> | `File of unit -> string | `Memory ]</code> </pre> <div class="info"> How to create the response body:<ul> <li><code class="code">`Memory</code>: The response body is in-memory</li> <li><code class="code">`File f</code>: The response body is stored into the file whose name is returned by <code class="code">f()</code></li> <li><code class="code">`Body f</code>: The response body is stored into the object returned by <code class="code">f()</code></li> </ul> <br> </div> <br><code><span class="keyword">type</span> <a name="TYPEsynchronization"></a><code class="type"></code>synchronization = </code><table class="typetable"> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Sync</span></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The next request begins after the response of the last request has been received.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code><span class="keyword">|</span></code></td> <td align="left" valign="top" > <code><span class="constructor">Pipeline</span> <span class="keyword">of</span> <code class="type">int</code></code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The client is allowed to send several requests without waiting for responses. The number is the maximum number of unreplied requests that are allowed. A typical value: 5. If you increase this value, the risk becomes higher that requests must be repeatedly sent to the server in the case the connection crashes. Increasing is recommended if you send a bigger number of GET or HEAD requests to the server. Decreasing is recommended if you send large POST or PUT requests to the server. <p> Values > 8 are interpreted as 8.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> <div class="info"> This type determines whether to keep requests and responses synchronized or not. <p> The first request/response round is always done in Sync mode, because the protocol version of the other side is not known at that moment. <code class="code">Pipeline</code> requires HTTP/1.1. <p> In previous versions of netclient there was a third option, <code class="code">Sync_with_handshake_before_request_body</code>. This option is no longer necessary because the HTTP specification has been updated in the meantime, and there is a better mechanism now (the <code class="code">Expect</code> header is set).<br> </div> <pre><span class="keyword">type</span> <a name="TYPEresolver"></a><code class="type"></code>resolver = <code class="type"><a href="Unixqueue.unix_event_system.html">Unixqueue.unix_event_system</a> -><br> string -> (Unix.inet_addr option -> unit) -> unit</code> </pre> <div class="info"> A name resolver is a function <code class="code">r</code> called as <code class="code">r esys name reply</code>. As <code class="code">name</code> the name to resolve is passed. The resolver must finally call <code class="code">reply</code> with either the resolved address or with <code class="code">None</code>, indicating an error in the latter case. The event system <code class="code">esys</code> can be used to carry out the resolution process in an asynchronous way, but this is optional. <p> Only 1:1 resolution is supported, 1:n resolution not.<br> </div> <br><code><span class="keyword">type</span> <a name="TYPEhttp_options"></a><code class="type"></code>http_options = {</code><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>synchronization : <code class="type"><a href="Http_client.html#TYPEsynchronization">synchronization</a></code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Default: <code class="code">Pipeline 5</code>.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>maximum_connection_failures : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >This option limits the number of connection attempts. Default: 2</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>maximum_message_errors : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >This option limits the number of protocol errors tolerated per request. If a request leads to a protocol error, the connection is shut down, the server is connected again, and the request is tried again (if the kind of the message allows retransmission). If a request repeatedly fails, this option limits the number of retransmissions. Default: 2</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>inhibit_persistency : <code class="type">bool</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >This option turns persistent connections off. Default: <code class="code">false</code> It is normally not necessary to change this option.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>connection_timeout : <code class="type">float</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >If there is no network transmission for this period of time, the connection is shut down, and tried again. Default: 300.0 (seconds) It may be necessary to increase this value if HTTP is used for batch applications that contact extremely slow services.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>number_of_parallel_connections : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The client keeps up to this number of parallel connections to a single content server or proxy. Default: 2 You may increase this value if you are mainly connected with an HTTP/1.0 proxy.</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>maximum_redirections : <code class="type">int</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The maximum number of redirections per message</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>handshake_timeout : <code class="type">float</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The timeout when waiting for "100 Continue". Default: 1.0</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>resolver : <code class="type"><a href="Http_client.html#TYPEresolver">resolver</a></code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The function for name resolution</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>configure_socket : <code class="type">Unix.file_descr -> unit</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >A function to configure socket options</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>verbose_status : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>verbose_request_header : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>verbose_response_header : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>verbose_request_contents : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>verbose_response_contents : <code class="type">bool</code>;</code></td> </tr> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>verbose_connection : <code class="type">bool</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Enable various debugging message types.<ul> <li><code class="code">verbose_status</code>: reports about status of received documents</li> <li><code class="code">verbose_request_header</code>: prints the header sent to the server</li> <li><code class="code">verbose_request_contents</code>: prints the document sent to the server</li> <li><code class="code">verbose_response_header</code>: prints the header of the answer from the server</li> <li><code class="code">verbose_response_contents</code>: prints the document received from the server</li> <li><code class="code">verbose_connection</code>: reports many connection events; authentication, too.</li> </ul> </td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> } <div class="info"> Options for the whole pipeline<br> </div> <pre><span class="keyword">type</span> <a name="TYPEheader_kind"></a><code class="type"></code>header_kind = <code class="type">[ `Base | `Effective ]</code> </pre> <div class="info"> The <code class="code">`Base</code> header is set by the user of <code class="code">http_call</code> and is never changed during processing the call. The <code class="code">`Effective</code> header is a copy of the base header at the time the request is sent. The effective header contains additions like <code class="code">Content-length</code> and authentication info.<br> </div> <pre><span class="keyword">class type</span> <a name="TYPEhttp_call"></a><a href="Http_client.http_call.html">http_call</a> = <code class="code">object</code> <a href="Http_client.http_call.html">..</a> <code class="code">end</code></pre><div class="info"> The container for HTTP calls </div> <br> <a name="1_HTTPmethods"></a> <h1>HTTP methods</h1><br> <pre><span class="keyword">class</span> <a name="TYPEgeneric_call"></a><span class="keyword">virtual</span> <a href="Http_client.generic_call.html">generic_call</a> : <code class="type"></code><code class="code">object</code> <a href="Http_client.generic_call.html">..</a> <code class="code">end</code></pre><div class="info"> This class is an implementation of <code class="code">http_call</code>. </div> <br> The following classes are implementations for the various HTTP methods. These classes do not initialize the call object.<br> <pre><span class="keyword">class</span> <a name="TYPEget_call"></a><a href="Http_client.get_call.html">get_call</a> : <code class="type"></code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><pre><span class="keyword">class</span> <a name="TYPEtrace_call"></a><a href="Http_client.trace_call.html">trace_call</a> : <code class="type"></code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><pre><span class="keyword">class</span> <a name="TYPEoptions_call"></a><a href="Http_client.options_call.html">options_call</a> : <code class="type"></code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><pre><span class="keyword">class</span> <a name="TYPEhead_call"></a><a href="Http_client.head_call.html">head_call</a> : <code class="type"></code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><pre><span class="keyword">class</span> <a name="TYPEpost_call"></a><a href="Http_client.post_call.html">post_call</a> : <code class="type"></code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><pre><span class="keyword">class</span> <a name="TYPEput_call"></a><a href="Http_client.put_call.html">put_call</a> : <code class="type"></code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><pre><span class="keyword">class</span> <a name="TYPEdelete_call"></a><a href="Http_client.delete_call.html">delete_call</a> : <code class="type"></code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><br> The following classes initialize the request message of the call (header and body). These classes are also backward compatible to the classes found in earlier versions of netclient.<br> <pre><span class="keyword">class</span> <a name="TYPEget"></a><a href="Http_client.get.html">get</a> : <code class="type">string -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Argument: URI </div> <pre><span class="keyword">class</span> <a name="TYPEtrace"></a><a href="Http_client.trace.html">trace</a> : <code class="type">string -> int -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Arguments: URI, maximum number of hops </div> <pre><span class="keyword">class</span> <a name="TYPEoptions"></a><a href="Http_client.options.html">options</a> : <code class="type">string -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Argument: URI or "*" </div> <pre><span class="keyword">class</span> <a name="TYPEhead"></a><a href="Http_client.head.html">head</a> : <code class="type">string -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Argument: URI </div> <pre><span class="keyword">class</span> <a name="TYPEpost"></a><a href="Http_client.post.html">post</a> : <code class="type">string -> (string * string) list -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Arguments: URI, parameter list to be transferred as application/x-www-form-urlencoded body </div> <pre><span class="keyword">class</span> <a name="TYPEpost_raw"></a><a href="Http_client.post_raw.html">post_raw</a> : <code class="type">string -> string -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Arguments: URI, body </div> <pre><span class="keyword">class</span> <a name="TYPEput"></a><a href="Http_client.put.html">put</a> : <code class="type">string -> string -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Arguments: URI, body </div> <pre><span class="keyword">class</span> <a name="TYPEdelete"></a><a href="Http_client.delete.html">delete</a> : <code class="type">string -> </code><code class="type"><a href="Http_client.http_call.html">http_call</a></code></pre><div class="info"> Argument: URI </div> <br> <a name="1_Authentication"></a> <h1>Authentication</h1><br> <pre><span class="keyword">class type</span> <a name="TYPEkey"></a><a href="Http_client.key.html">key</a> = <code class="code">object</code> <a href="Http_client.key.html">..</a> <code class="code">end</code></pre><div class="info"> A <code class="code">key</code> is a user/password combination for a certain realm </div> <pre><span class="keyword">class type</span> <a name="TYPEkey_handler"></a><a href="Http_client.key_handler.html">key_handler</a> = <code class="code">object</code> <a href="Http_client.key_handler.html">..</a> <code class="code">end</code></pre><pre><span class="keyword">class</span> <a name="TYPEkey_ring"></a><a href="Http_client.key_ring.html">key_ring</a> : <code class="type">?uplink:#<a href="Http_client.key_handler.html">key_handler</a> -> unit -> </code><code class="code">object</code> <a href="Http_client.key_ring.html">..</a> <code class="code">end</code></pre><div class="info"> The <code class="code">key_ring</code> is a cache for keys. </div> <pre><span class="keyword">class type</span> <a name="TYPEauth_session"></a><a href="Http_client.auth_session.html">auth_session</a> = <code class="code">object</code> <a href="Http_client.auth_session.html">..</a> <code class="code">end</code></pre><div class="info"> An <code class="code">auth_session</code> represents an authenticated session </div> <pre><span class="keyword">class type</span> <a name="TYPEauth_handler"></a><a href="Http_client.auth_handler.html">auth_handler</a> = <code class="code">object</code> <a href="Http_client.auth_handler.html">..</a> <code class="code">end</code></pre><div class="info"> An authentication handler has the capability of adding the necessary headers to messages. </div> <pre><span class="keyword">class</span> <a name="TYPEbasic_auth_handler"></a><a href="Http_client.basic_auth_handler.html">basic_auth_handler</a> : <code class="type">?enable_auth_in_advance:bool -> #<a href="Http_client.key_handler.html">key_handler</a> -> </code><code class="type"><a href="Http_client.auth_handler.html">auth_handler</a></code></pre><div class="info"> Basic authentication. </div> <pre><span class="keyword">class</span> <a name="TYPEdigest_auth_handler"></a><a href="Http_client.digest_auth_handler.html">digest_auth_handler</a> : <code class="type">?enable_auth_in_advance:bool -> #<a href="Http_client.key_handler.html">key_handler</a> -> </code><code class="type"><a href="Http_client.auth_handler.html">auth_handler</a></code></pre><div class="info"> Digest authentication. </div> <pre><span class="keyword">class</span> <a name="TYPEbasic_auth_method"></a><a href="Http_client.basic_auth_method.html">basic_auth_method</a> : <code class="type"></code><code class="code">object</code> <a href="Http_client.basic_auth_method.html">..</a> <code class="code">end</code></pre><div class="info"> <b>Deprecated.</b> </div> <pre><span class="keyword">class</span> <a name="TYPEdigest_auth_method"></a><a href="Http_client.digest_auth_method.html">digest_auth_method</a> : <code class="type"></code><code class="type"><a href="Http_client.basic_auth_method.html">basic_auth_method</a></code></pre><div class="info"> <b>Deprecated.</b> </div> <br> <a name="1_Pipelines"></a> <h1>Pipelines</h1><br> <br> A connection cache is an object that keeps connections open that are currently unused. A connection cache can be shared by several pipelines.<br> <pre><span class="keyword">type</span> <a name="TYPEconnection_cache"></a><code class="type"></code>connection_cache </pre> <pre><span class="keyword">val</span> <a name="VALclose_connection_cache"></a>close_connection_cache : <code class="type"><a href="Http_client.html#TYPEconnection_cache">connection_cache</a> -> unit</code></pre><div class="info"> Closes all descriptors known to the cache<br> </div> <pre><span class="keyword">val</span> <a name="VALcreate_restrictive_cache"></a>create_restrictive_cache : <code class="type">unit -> <a href="Http_client.html#TYPEconnection_cache">connection_cache</a></code></pre><div class="info"> A restrictive cache closes connections as soon as there are no pending requests.<br> </div> <pre><span class="keyword">val</span> <a name="VALcreate_aggressive_cache"></a>create_aggressive_cache : <code class="type">unit -> <a href="Http_client.html#TYPEconnection_cache">connection_cache</a></code></pre><div class="info"> This type of cache tries to keep connections as long open as possible. The consequence is that users are responsible for closing the descriptors (by calling <code class="code">close_connection_cache</code>) when the cache is no longer in use. <p> Aggressive caching is an experimental feature. Reports about success and/or problems are very welcome.<br> </div> <pre><span class="keyword">class</span> <a name="TYPEpipeline"></a><a href="Http_client.pipeline.html">pipeline</a> : <code class="type"></code><code class="code">object</code> <a href="Http_client.pipeline.html">..</a> <code class="code">end</code></pre><div class="info"> A pipeline is a queue of HTTP calls to perform </div> <br> <b>Example using the pipeline:</b> <p> <pre><code class="code"> let call = new get "http://server/path" in let pipeline = new pipeline in pipeline # add call; pipeline # run(); (* Now the HTTP client is working... *) match call # status with | `Successful -> ... | ... </code></pre><br> <br> <a name="1_Conveniencemoduleforsimpleapplications"></a> <h1>Convenience module for simple applications</h1><br> <br> Do <code class="code">open Http_client.Convenience</code> for simple applications.<br> <pre><span class="keyword">module</span> <a href="Http_client.Convenience.html">Convenience</a>: <code class="code">sig</code> <a href="Http_client.Convenience.html">..</a> <code class="code">end</code></pre></body></html>