UNPKG

@ciao-lang/ts-ciao-interface

Version:

Simple Ciao interface for node.

26 lines 12.8 kB
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>HTTP messages (response and request) &mdash; The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">&#9776;</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="http_doc.html">&#x2191;</a><a class="lpdoc-navbutton" href="cgi.html">&#x2190;</a><a class="lpdoc-navbutton" href="http_date.html">&#x2192;</a><a class="lpdoc-navbutton" href="ciaosearch.html">&#x1F50D;</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> &raquo;<br/> </li><li><a href="ExtraLibs.html">PART VIII - Additional libraries</a> &raquo;<br/> </li><li><a href="http_doc.html">HTTP client/server libraries</a> &raquo;<br/> </li><li><a href=""><strong>HTTP messages (response and request)</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on exports">Documentation on exports</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>HTTP messages (response and request)</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#http_messages"></a> <strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="The Ciao Development Team" href="ciaosearch.html#The Ciao Development Team">The Ciao Development Team</a>.<p> <p>Parser/printer for HTTP response and request messages.<p>See <a href="https://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC2616</a> for a reference of HTTP/1.1 protocol.<p>The request and response objects are represented as list of terms, which represent HTTP header fields and other elements (such as the status, and contents).<p>The current list of <strong>request</strong> headers is:<p><ul> <li><strong>method(</strong><em>Method</em><strong>):</strong> <em>Method</em> is the HTTP method in lowercase (<tt>head</tt>, <tt>get</tt>, <tt>post</tt>, etc.).<p><li><strong>timeout(</strong><em>T</em><strong>):</strong> <em>T</em> specifies the time in seconds to wait for the response. Default is 300 seconds.<p><li><strong>if_modified_since(</strong><em>Date</em><strong>):</strong> Get document only if newer than <em>Date</em>. <em>Date</em> has the format defined by <a class="lpdoc-idx-anchor" id="0" href="http_date.html#http_date/1"><tt>http_date/1</tt></a>.<p><li><strong>user_agent(</strong><em>Agent</em><strong>):</strong> Provides a user-agent field, <em>Agent</em> is an atom.<p><li><strong>authorization(</strong><em>Scheme</em>,<em>Params</em><strong>):</strong> To provide credentials. See RFC 1945 for details.<p><li><strong><em>option</em>(</strong><em>Value</em><strong>):</strong> Any unary term, being <em>Value</em> an atom, can be used to provide another valid option (e.g. <tt>from(&apos;user@machine&apos;)</tt>). <p></ul> <p>The current list of <strong>response</strong> headers is: <ul> <p><li><strong>status(</strong><em>Type,Code,Reason</em><strong>):</strong> <em>Type</em> is an atom denoting the response type, <em>Code</em> is the status code (an integer), and <em>Reason</em> is a string holding the reason phrase.<p><li><strong>date(</strong><em>Date</em><strong>):</strong> <em>Date</em> is the date of the response, with format defined by <a class="lpdoc-idx-anchor" id="1" href="http_date.html#http_date/1"><tt>http_date/1</tt></a>.<p><li><strong>location(</strong><em>Loc</em><strong>):</strong> This parameter appears when the document has moved, <em>Loc</em> is an atom holding the new location.<p><li><strong>server(</strong><em>Server</em><strong>):</strong> <em>Server</em> is the server responding, as an atom.<p><li><strong>www_authenticate(</strong><em>Params</em><strong>):</strong> Returned if document is protected, <em>Params</em> is a list of chagenges. See RFC 1945 for details.<p><li><strong>allow(</strong><em>Methods</em><strong>):</strong> <em>Methods</em> are the methods allowed by the server, as a list of atoms.<p><li><strong>content_encoding(</strong><em>Encoding</em><strong>):</strong> <em>Encoding</em> is an atom defining the encoding.<p><li><strong>expires(</strong><em>Date</em><strong>):</strong> <em>Date</em> is the date after which the entity should be considered stale. Format defined by <a class="lpdoc-idx-anchor" id="2" href="http_date.html#http_date/1"><tt>http_date/1</tt></a>.<p><li><strong>last_modified(</strong><em>Date</em><strong>):</strong> <em>Date</em> is the date at which the sender believes the resource was last modified. Format defined by <a class="lpdoc-idx-anchor" id="3" href="http_date.html#http_date/1"><tt>http_date/1</tt></a>.<p><li><strong>pragma(</strong><em>String</em><strong>):</strong> Miscellaneous data.<p><li><strong><em>header</em>(</strong><em>String</em><strong>):</strong> Any other functor <em>header</em>/1 is an extension header. </ul> <p>The current list of some common headers is: <ul> <p><li><strong>content_length(</strong><em>Length</em><strong>):</strong> <em>Length</em> is the length of the document (an integer). <p><li><strong>content_type(</strong><em>Type,Subtype,Params</em><strong>):</strong> Specifies the document content type, <em>Type</em> and <em>Subtype</em> are atoms, <em>Params</em> a list of parameters (e.g. <tt>content_type(text,html,[])</tt>). <p><li><strong>content(</strong><em>Bytes</em><strong>):</strong> <em>Bytes</em> is the document content (bytelist/1). If <tt>method(head)</tt> of the HTTP request is used, an empty list is get here.<p></ul><br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_module(library(http/http_messages)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="4" href="#http_request_str/4"><tt>http_request_str/4</tt></a>, <a class="lpdoc-idx-anchor" id="5" href="#name_to_method/2"><tt>name_to_method/2</tt></a>, <a class="lpdoc-idx-anchor" id="6" href="#http_response_str/3"><tt>http_response_str/3</tt></a>. <li><em>Regular Types:</em><br/><a class="lpdoc-idx-anchor" id="7" href="#http_request_param/1"><tt>http_request_param/1</tt></a>, <a class="lpdoc-idx-anchor" id="8" href="#http_response_param/1"><tt>http_response_param/1</tt></a>. </ul></ul></div></div><div id="Documentation on exports"><h2>Documentation on exports</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="http_request_param/1" href="ciaosearch.html#http_request_param/1">http_request_param/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>http_request_param(Request)</tt> </span><p><span class="lpdoc-var">Request</span> is a parameter of an HTTP request.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="http_request_str/4" href="ciaosearch.html#http_request_str/4">http_request_str/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage 1:</span><span class="lpdoc-usage-decl"><tt>http_request_str(RequestURI,Request,RequestBytes,RequestBytesTail)</tt> </span><p>Parse a string into an HTTP request</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="9" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">RequestURI</span> is a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="10" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Request</span> is a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="11" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">RequestBytes</span> is currently a term which is not a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="12" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">RequestBytesTail</span> is currently a term which is not a free variable. </span> </ul><p><span class="lpdoc-usage-header">Usage 2:</span><span class="lpdoc-usage-decl"><tt>http_request_str(RequestURI,Request,RequestBytes,RequestBytesTail)</tt> </span><p>Generate an HTTP request from a list of parameters</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="13" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">RequestURI</span> is currently a term which is not a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="14" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Request</span> is currently a term which is not a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="15" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">RequestBytes</span> is a free variable. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="16" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">RequestBytesTail</span> is a free variable. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="name_to_method/2" href="ciaosearch.html#name_to_method/2">name_to_method/2</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="http_response_param/1" href="ciaosearch.html#http_response_param/1">http_response_param/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>http_response_param(Response)</tt> </span><p><span class="lpdoc-var">Response</span> is a parameter of an HTTP response.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="http_response_str/3" href="ciaosearch.html#http_response_str/3">http_response_str/3</a></div><div class="lpdoc-deftext">No further documentation available for this predicate.</div></div><p> </div><div id="Documentation on imports"><h2>Documentation on imports</h2>This module has the following direct dependencies:<ul class="lpdoc-itemize-minus"><li><em>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="17" href="lists.html"><tt>lists</tt></a>, <a class="lpdoc-idx-anchor" id="18" href="http_grammar.html"><tt>http_grammar</tt></a>, <a class="lpdoc-idx-anchor" id="19" href="http_date.html"><tt>http_date</tt></a>. <li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="20" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="21" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="22" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="23" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="24" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="25" href="regtypes_doc.html"><tt>regtypes</tt></a>, <a class="lpdoc-idx-anchor" id="26" href="isomodes_doc.html"><tt>isomodes</tt></a>, <a class="lpdoc-idx-anchor" id="27" href="dcg_doc.html"><tt>dcg</tt></a>, <a class="lpdoc-idx-anchor" id="28" href="ciaosearch.html#hiord"><tt>hiord</tt></a>, <a class="lpdoc-idx-anchor" id="29" href="doccomments_doc.html"><tt>doccomments</tt></a>. </ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>