<!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="Netaux.html"> <link rel="next" href="Netchannels_tut.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="Parsing and Printing of Headers" rel="Section" href="#2_ParsingandPrintingofHeaders"> <title>Ocamlnet 2 Reference Manual : Nethttp</title> </head> <body> <div class="navbar"><a href="Netaux.html">Previous</a> <a href="index.html">Up</a> <a href="Netchannels_tut.html">Next</a> </div> <center><h1>Module <a href="type_Nethttp.html">Nethttp</a></h1></center> <br> <pre><span class="keyword">module</span> Nethttp: <code class="code">sig</code> <a href="Nethttp.html">..</a> <code class="code">end</code></pre><a name="1_BasicdefinitionsfortheHTTPprotocol"></a> <h1>Basic definitions for the HTTP protocol</h1><br> <hr width="100%"> <br> These definitions can be used by both HTTP clients and servers, and by protocols in the middle, e.g. CGI.<br> <pre><span class="keyword">type</span> <a name="TYPEprotocol_version"></a><code class="type"></code>protocol_version = <code class="type">int * int</code> </pre> <br> A pair of a major and minor version number<br> <pre><span class="keyword">type</span> <a name="TYPEprotocol_attribute"></a><code class="type"></code>protocol_attribute = <code class="type">[ `Secure_https ]</code> </pre> <pre><span class="keyword">type</span> <a name="TYPEprotocol"></a><code class="type"></code>protocol = <code class="type">[ `Http of <a href="Nethttp.html#TYPEprotocol_version">protocol_version</a> * <a href="Nethttp.html#TYPEprotocol_attribute">protocol_attribute</a> list<br> | `Other ]</code> </pre> <div class="info"> The base protocol. RFC 2145 defines how to interpret major and minor numbers. In particular, we have:<ul> <li><code class="code">`Http((0,9),_)</code> is the ancient HTTP version 0.9</li> <li><code class="code">`Http((1,n),_)</code> is the HTTP protocol 1.n. It is expected that all these versions are compatible to each other except negotiable features.</li> <li><code class="code">`Http((m,_),_)</code> for m>1 is regarded as unknown protocol, incompatible to any <code class="code">`Http((1,n),_)</code></li> <li><code class="code">`Other</code> is anything else (unrecognizes protocol)</li> </ul> <br> </div> <pre><span class="keyword">val</span> <a name="VALstring_of_protocol"></a>string_of_protocol : <code class="type"><a href="Nethttp.html#TYPEprotocol">protocol</a> -> string</code></pre><div class="info"> Returns the string representation, e.g. "HTTP/1.0". Fails for <code class="code">`Other</code><br> </div> <pre><span class="keyword">val</span> <a name="VALprotocol_of_string"></a>protocol_of_string : <code class="type">string -> <a href="Nethttp.html#TYPEprotocol">protocol</a></code></pre><div class="info"> Parses the protocol string, e.g. "HTTP/1.0". Returns <code class="code">`Other</code> for unrecognized strings<br> </div> <pre><span class="keyword">type</span> <a name="TYPEhttp_status"></a><code class="type"></code>http_status = <code class="type">[ `Accepted<br> | `Bad_gateway<br> | `Bad_request<br> | `Conflict<br> | `Continue<br> | `Created<br> | `Expectation_failed<br> | `Forbidden<br> | `Found<br> | `Gateway_timeout<br> | `Gone<br> | `Http_version_not_supported<br> | `Internal_server_error<br> | `Length_required<br> | `Method_not_allowed<br> | `Moved_permanently<br> | `Multiple_choices<br> | `No_content<br> | `Non_authoritative<br> | `Not_acceptable<br> | `Not_found<br> | `Not_implemented<br> | `Not_modified<br> | `Ok<br> | `Partial_content<br> | `Payment_required<br> | `Precondition_failed<br> | `Proxy_auth_required<br> | `Request_entity_too_large<br> | `Request_timeout<br> | `Request_uri_too_long<br> | `Requested_range_not_satisfiable<br> | `Reset_content<br> | `See_other<br> | `Service_unavailable<br> | `Switching_protocols<br> | `Temporary_redirect<br> | `Unauthorized<br> | `Unsupported_media_type<br> | `Use_proxy ]</code> </pre> <div class="info"> HTTP response status: <p> <b>Informational (1xx):</b><ul> <li><code class="code">`Continue</code></li> <li><code class="code">`Switching_protocols</code></li> </ul> <b>Successful (2xx):</b><ul> <li><code class="code">`Ok</code></li> <li><code class="code">`Created</code></li> <li><code class="code">`Accepted</code></li> <li><code class="code">`Non_authoritative</code></li> <li><code class="code">`No_content</code></li> <li><code class="code">`Reset_content</code></li> <li><code class="code">`Partial_content</code></li> </ul> <b>Redirection (3xx):</b><ul> <li><code class="code">`Multiple_choices</code></li> <li><code class="code">`Moved_permanently</code></li> <li><code class="code">`Found</code></li> <li><code class="code">`See_other</code></li> <li><code class="code">`Not_modified</code></li> <li><code class="code">`Use_proxy</code></li> <li><code class="code">`Temporary_redirect</code></li> </ul> <b>Client error (4xx):</b><ul> <li><code class="code">`Bad_request</code></li> <li><code class="code">`Unauthorized</code></li> <li><code class="code">`Payment_required</code></li> <li><code class="code">`Forbidden</code></li> <li><code class="code">`Not_found</code></li> <li><code class="code">`Method_not_allowed</code></li> <li><code class="code">`Not_acceptable</code></li> <li><code class="code">`Proxy_auth_required</code></li> <li><code class="code">`Request_timeout</code></li> <li><code class="code">`Conflict</code></li> <li><code class="code">`Gone</code></li> <li><code class="code">`Length_required</code></li> <li><code class="code">`Precondition_failed</code></li> <li><code class="code">`Request_entity_too_large</code></li> <li><code class="code">`Request_uri_too_long</code></li> <li><code class="code">`Unsupported_media_type</code></li> <li><code class="code">`Request_range_not_satisfiable</code></li> <li><code class="code">`Expectation_failed</code></li> </ul> <b>Server Error (5xx):</b><ul> <li><code class="code">`Internal_server_error</code></li> <li><code class="code">`Not_implemented</code></li> <li><code class="code">`Bad_gateway</code></li> <li><code class="code">`Service_unavailable</code></li> <li><code class="code">`Gateway_timeout</code></li> <li><code class="code">`Http_version_not_supported</code></li> </ul> <br> </div> <pre><span class="keyword">val</span> <a name="VALint_of_http_status"></a>int_of_http_status : <code class="type"><a href="Nethttp.html#TYPEhttp_status">http_status</a> -> int</code></pre><div class="info"> Returns the integer code for a status value<br> </div> <pre><span class="keyword">val</span> <a name="VALhttp_status_of_int"></a>http_status_of_int : <code class="type">int -> <a href="Nethttp.html#TYPEhttp_status">http_status</a></code></pre><div class="info"> Returns the status value for an integer code, or raises <code class="code">Not_found</code><br> </div> <pre><span class="keyword">val</span> <a name="VALstring_of_http_status"></a>string_of_http_status : <code class="type"><a href="Nethttp.html#TYPEhttp_status">http_status</a> -> string</code></pre><div class="info"> Returns the informational text for a status value<br> </div> <pre><span class="keyword">type</span> <a name="TYPEhttp_method"></a><code class="type"></code>http_method = <code class="type">string * string</code> </pre> <div class="info"> Method name, URI<br> </div> <pre><span class="keyword">type</span> <a name="TYPEcache_control_token"></a><code class="type"></code>cache_control_token = <code class="type">[ `Extension of string * string option<br> | `Max_age of int<br> | `Max_stale of int option<br> | `Min_fresh of int<br> | `Must_revalidate<br> | `No_cache of string list<br> | `No_store<br> | `No_transform<br> | `Only_if_cached<br> | `Private of string list<br> | `Proxy_revalidate<br> | `Public<br> | `S_maxage of int ]</code> </pre> <div class="info"> The cache control token for the <code class="code">Cache-control</code> header<br> </div> <pre><span class="keyword">type</span> <a name="TYPEetag"></a><code class="type"></code>etag = <code class="type">[ `Strong of string | `Weak of string ]</code> </pre> <div class="info"> Entity tags can be weak or strong<br> </div> <pre><span class="keyword">val</span> <a name="VALweak_validator_match"></a>weak_validator_match : <code class="type"><a href="Nethttp.html#TYPEetag">etag</a> -> <a href="Nethttp.html#TYPEetag">etag</a> -> bool</code></pre><div class="info"> Whether the tags match weakly (see RFC 2616 for definition)<br> </div> <pre><span class="keyword">val</span> <a name="VALstrong_validator_match"></a>strong_validator_match : <code class="type"><a href="Nethttp.html#TYPEetag">etag</a> -> <a href="Nethttp.html#TYPEetag">etag</a> -> bool</code></pre><div class="info"> Whether the tags match strongly (see RFC 2616 for definition)<br> </div> <pre><span class="keyword">exception</span> <a name="EXCEPTIONBad_header_field"></a>Bad_header_field <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> Raised when a header field cannot be parsed. The string argument is the name of the failing function<br> </div> <pre><span class="keyword">class type</span> <a name="TYPEhttp_header"></a><a href="Nethttp.http_header.html">http_header</a> = <code class="type"><a href="Netmime.mime_header.html">Netmime.mime_header</a></code></pre><pre><span class="keyword">class type</span> <a name="TYPEhttp_header_ro"></a><a href="Nethttp.http_header_ro.html">http_header_ro</a> = <code class="type"><a href="Netmime.mime_header_ro.html">Netmime.mime_header_ro</a></code></pre><div class="info"> The HTTP header is represented as MIME header </div> <pre><span class="keyword">class type</span> <a name="TYPEhttp_trailer"></a><a href="Nethttp.http_trailer.html">http_trailer</a> = <code class="type"><a href="Netmime.mime_header.html">Netmime.mime_header</a></code></pre><pre><span class="keyword">class type</span> <a name="TYPEhttp_trailer_ro"></a><a href="Nethttp.http_trailer_ro.html">http_trailer_ro</a> = <code class="type"><a href="Netmime.mime_header_ro.html">Netmime.mime_header_ro</a></code></pre><div class="info"> The HTTP trailer is represented as MIME header </div> <pre><span class="keyword">val</span> <a name="VALstatus_of_cgi_header"></a>status_of_cgi_header : <code class="type"><a href="Nethttp.http_header.html">http_header</a> -> int * string</code></pre><div class="info"> Returns the status code and the status text corresponding to the <code class="code">Status</code> header<br> </div> <br><code><span class="keyword">type</span> <a name="TYPEcookie"></a><code class="type"></code>cookie = {</code><table class="typetable"> <tr> <td align="left" valign="top" > <code> </code></td> <td align="left" valign="top" > <code>cookie_name : <code class="type">string</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The name of the cookie</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>cookie_value : <code class="type">string</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >The value of the cookie. There are no restrictions on the value of the cookie</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>cookie_expires : <code class="type">float option</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Expiration:<ul> <li><code class="code">None</code>: the cookie expires when the browser session ends.</li> <li><code class="code">Some t</code>: the cookie expires at the time <code class="code">t</code> (seconds since the epoch)</li> </ul> </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>cookie_domain : <code class="type">string option</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Cookies are bound to a certain domain, i.e. the browser sends them only when web pages of the domain are requested: <p> <ul> <li><code class="code">None</code>: the domain is the hostname of the server</li> <li><code class="code">Some domain</code>: the domain is <code class="code">domain</code></li> </ul> </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>cookie_path : <code class="type">string option</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Cookies are also bound to certain path prefixes, i.e. the browser sends them only when web pages at the path or below are requested. <p> <ul> <li><code class="code">None</code>: the path is script name + path_info</li> <li><code class="code">Some p</code>: the path is <code class="code">p</code>. With <code class="code">Some "/"</code> you can disable the path restriction completely.</li> </ul> </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>cookie_secure : <code class="type">bool</code>;</code></td> <td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" >Cookies are also bound to the type of the web server: <code class="code">false</code> means servers without SSL, <code class="code">true</code> means servers with activated SSL ("https").</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td> </tr></table> } <pre><span class="keyword">val</span> <a name="VALdecode_query"></a>decode_query : <code class="type">string -> string * string</code></pre><div class="info"> Splits the URI into a "script name" and a "query string"<br> </div> <pre><span class="keyword">val</span> <a name="VALsplit_host_port"></a>split_host_port : <code class="type">string -> string * int option</code></pre><div class="info"> Splits the <code class="code">Host</code> header in hostname and optional port number. Fails on syntax error<br> </div> <pre><span class="keyword">val</span> <a name="VALuripath_encode"></a>uripath_encode : <code class="type">string -> string</code></pre><div class="info"> Encodes unsafe characters in URI paths. The slash character is not encoded. This function should only be applied to the part before '?'.<br> </div> <pre><span class="keyword">val</span> <a name="VALuripath_decode"></a>uripath_decode : <code class="type">string -> string</code></pre><div class="info"> Decodes %XX sequences in URI paths. %2F is forbidden (failure). This function should only be applied to the part before '?'.<br> </div> <br> <a name="2_ParsingandPrintingofHeaders"></a> <h2>Parsing and Printing of Headers</h2><br> <pre><span class="keyword">module</span> <a href="Nethttp.Header.html">Header</a>: <code class="code">sig</code> <a href="Nethttp.Header.html">..</a> <code class="code">end</code></pre></body></html>