1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <title>Reference</title>
6 <link rel="stylesheet" href="../luadoc.css" type="text/css" />
7 <!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
14 <div id="product_logo"></div>
15 <div id="product_name"><big><b></b></big></div>
16 <div id="product_description"></div>
17 </div> <!-- id="product" -->
27 <li><a href="../index.html">Index</a></li>
38 <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
42 <a href="../modules/luci.http.html">luci.http</a>
45 <li><strong>luci.http.protocol</strong></li>
48 <a href="../modules/luci.http.protocol.conditionals.html">luci.http.protocol.conditionals</a>
52 <a href="../modules/luci.http.protocol.date.html">luci.http.protocol.date</a>
56 <a href="../modules/luci.http.protocol.mime.html">luci.http.protocol.mime</a>
60 <a href="../modules/luci.i18n.html">luci.i18n</a>
64 <a href="../modules/luci.ip.html">luci.ip</a>
68 <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
72 <a href="../modules/luci.json.html">luci.json</a>
76 <a href="../modules/luci.jsonc.html">luci.jsonc</a>
80 <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
84 <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
88 <a href="../modules/luci.model.uci.html">luci.model.uci</a>
92 <a href="../modules/luci.rpcc.html">luci.rpcc</a>
96 <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
100 <a href="../modules/luci.sys.html">luci.sys</a>
104 <a href="../modules/luci.sys.init.html">luci.sys.init</a>
108 <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
112 <a href="../modules/luci.sys.net.html">luci.sys.net</a>
116 <a href="../modules/luci.sys.process.html">luci.sys.process</a>
120 <a href="../modules/luci.sys.user.html">luci.sys.user</a>
124 <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
128 <a href="../modules/luci.util.html">luci.util</a>
132 <a href="../modules/nixio.html">nixio</a>
136 <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
140 <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
144 <a href="../modules/nixio.File.html">nixio.File</a>
148 <a href="../modules/nixio.README.html">nixio.README</a>
152 <a href="../modules/nixio.Socket.html">nixio.Socket</a>
156 <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
160 <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
164 <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
168 <a href="../modules/nixio.bin.html">nixio.bin</a>
172 <a href="../modules/nixio.bit.html">nixio.bit</a>
176 <a href="../modules/nixio.crypto.html">nixio.crypto</a>
180 <a href="../modules/nixio.fs.html">nixio.fs</a>
195 </div><!-- id="navigation" -->
199 <h1>Class <code>luci.http.protocol</code></h1>
210 <table class="function_list">
213 <td class="name" nowrap><a href="#header_source">header_source</a> (sock)</td>
216 Creates a ltn12 source from the given socket.</td>
220 <td class="name" nowrap><a href="#mimedecode_message_body">mimedecode_message_body</a> (src, msg, filecb)</td>
223 Decode a mime encoded http message body with multipart/form-data
229 <td class="name" nowrap><a href="#parse_message_body">parse_message_body</a> (src, msg, filecb)</td>
232 Try to extract and decode a http message body from the given ltn12 source.</td>
236 <td class="name" nowrap><a href="#parse_message_header">parse_message_header</a> (src)</td>
239 Try to extract an http message header including information like protocol
241 version, message headers and resulting CGI environment variables from the
242 given ltn12 source.</td>
246 <td class="name" nowrap><a href="#urldecode">urldecode</a> (str, no_plus)</td>
249 Decode an urlencoded string - optionally without decoding
251 the "+" sign to " " - and return the decoded string.</td>
255 <td class="name" nowrap><a href="#urldecode_message_body">urldecode_message_body</a> (src, msg)</td>
258 Decode an urlencoded http message body with application/x-www-urlencoded
264 <td class="name" nowrap><a href="#urldecode_params">urldecode_params</a> (url, tbl)</td>
267 Extract and split urlencoded data pairs, separated bei either "&" or ";"
269 from given url or string.</td>
273 <td class="name" nowrap><a href="#urlencode">urlencode</a> (str)</td>
276 Encode given string to x-www-urlencoded format.</td>
280 <td class="name" nowrap><a href="#urlencode_params">urlencode_params</a> (tbl)</td>
283 Encode each key-value-pair in given table to x-www-urlencoded format,
285 separated by "&".</td>
299 <h2><a name="functions"></a>Functions</h2>
300 <dl class="function">
304 <dt><a name="header_source"></a><strong>header_source</strong> (sock)</dt>
308 Creates a ltn12 source from the given socket. The source will return it's
310 data line by line with the trailing \r\n stripped of.
317 sock: Readable network socket
327 <h3>Return value:</h3>
328 Ltn12 source function
337 <dt><a name="mimedecode_message_body"></a><strong>mimedecode_message_body</strong> (src, msg, filecb)</dt>
341 Decode a mime encoded http message body with multipart/form-data
343 Content-Type. Stores all extracted data associated with its parameter name
344 in the params table within the given message object. Multiple parameter
345 values are stored as tables, ordinary ones as strings.
346 If an optional file callback function is given then it is feeded with the
347 file contents chunk by chunk and only the extracted file name is stored
348 within the params table. The callback function will be called subsequently
349 with three arguments:
350 o Table containing decoded (name, file) and raw (headers) mime header data
351 o String value containing a chunk of the file data
352 o Boolean which indicates wheather the current chunk is the last one (eof)
359 src: Ltn12 source function
363 msg: HTTP message object
367 filecb: File callback function (optional)
377 <h3>Return values:</h3>
380 <li>Value indicating successful operation (not nil means "ok")
382 <li>String containing the error if unsuccessful
391 <li><a href="#parse_message_header">
402 <dt><a name="parse_message_body"></a><strong>parse_message_body</strong> (src, msg, filecb)</dt>
406 Try to extract and decode a http message body from the given ltn12 source.
408 This function will examine the Content-Type within the given message object
409 to select the appropriate content decoder.
410 Currently the application/x-www-urlencoded and application/form-data
411 mime types are supported. If the encountered content encoding can't be
412 handled then the whole message body will be stored unaltered as "content"
413 property within the given message object.
420 src: Ltn12 source function
424 msg: HTTP message object
428 filecb: File data callback (optional, see mimedecode_message_body())
438 <h3>Return values:</h3>
441 <li>Value indicating successful operation (not nil means "ok")
443 <li>String containing the error if unsuccessful
452 <li><a href="#parse_message_header">
463 <dt><a name="parse_message_header"></a><strong>parse_message_header</strong> (src)</dt>
467 Try to extract an http message header including information like protocol
469 version, message headers and resulting CGI environment variables from the
477 src: Ltn12 source function
487 <h3>Return value:</h3>
495 <li><a href="#parse_message_body">
506 <dt><a name="urldecode"></a><strong>urldecode</strong> (str, no_plus)</dt>
510 Decode an urlencoded string - optionally without decoding
512 the "+" sign to " " - and return the decoded string.
519 str: Input string in x-www-urlencoded format
523 no_plus: Don't decode "+" signs to spaces
533 <h3>Return value:</h3>
541 <li><a href="#urlencode">
552 <dt><a name="urldecode_message_body"></a><strong>urldecode_message_body</strong> (src, msg)</dt>
556 Decode an urlencoded http message body with application/x-www-urlencoded
558 Content-Type. Stores all extracted data associated with its parameter name
559 in the params table within the given message object. Multiple parameter
560 values are stored as tables, ordinary ones as strings.
567 src: Ltn12 source function
571 msg: HTTP message object
581 <h3>Return values:</h3>
584 <li>Value indicating successful operation (not nil means "ok")
586 <li>String containing the error if unsuccessful
595 <li><a href="#parse_message_header">
606 <dt><a name="urldecode_params"></a><strong>urldecode_params</strong> (url, tbl)</dt>
610 Extract and split urlencoded data pairs, separated bei either "&" or ";"
612 from given url or string. Returns a table with urldecoded values.
613 Simple parameters are stored as string values associated with the parameter
614 name within the table. Parameters with multiple values are stored as array
615 containing the corresponding values.
622 url: The url or string which contains x-www-urlencoded form data
626 tbl: Use the given table for storing values (optional)
636 <h3>Return value:</h3>
637 Table containing the urldecoded parameters
644 <li><a href="#urlencode_params">
655 <dt><a name="urlencode"></a><strong>urlencode</strong> (str)</dt>
659 Encode given string to x-www-urlencoded format.
667 str: String to encode
677 <h3>Return value:</h3>
678 String containing the encoded data
685 <li><a href="#urldecode">
696 <dt><a name="urlencode_params"></a><strong>urlencode_params</strong> (tbl)</dt>
700 Encode each key-value-pair in given table to x-www-urlencoded format,
702 separated by "&". Tables are encoded as parameters with multiple values by
703 repeating the parameter name with each value.
710 tbl: Table with the values
720 <h3>Return value:</h3>
721 String containing encoded values
728 <li><a href="#urldecode_params">
743 </div> <!-- id="content" -->
745 </div> <!-- id="main" -->
748 <p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
749 </div> <!-- id="about" -->
751 </div> <!-- id="container" -->