Fix module lines in several luadoc files
[project/luci.git] / doc / modules / luci.http.protocol.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html>
4 <head>
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"/-->
8 </head>
9
10 <body>
11 <div id="container">
12
13 <div id="product">
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" -->
18
19 <div id="main">
20
21 <div id="navigation">
22
23
24 <h1>LuaDoc</h1>
25 <ul>
26         
27         <li><a href="../index.html">Index</a></li>
28         
29 </ul>
30
31
32 <!-- Module list -->
33
34 <h1>Modules</h1>
35 <ul>
36
37         <li>
38                 <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
39         </li>
40
41         <li><strong>luci.http.protocol</strong></li>
42         
43         <li>
44                 <a href="../modules/luci.http.protocol.conditionals.html">luci.http.protocol.conditionals</a>
45         </li>
46
47         <li>
48                 <a href="../modules/luci.http.protocol.date.html">luci.http.protocol.date</a>
49         </li>
50
51         <li>
52                 <a href="../modules/luci.http.protocol.mime.html">luci.http.protocol.mime</a>
53         </li>
54
55         <li>
56                 <a href="../modules/luci.i18n.html">luci.i18n</a>
57         </li>
58
59         <li>
60                 <a href="../modules/luci.ip.html">luci.ip</a>
61         </li>
62
63         <li>
64                 <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
65         </li>
66
67         <li>
68                 <a href="../modules/luci.jsonc.html">luci.jsonc</a>
69         </li>
70
71         <li>
72                 <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
73         </li>
74
75         <li>
76                 <a href="../modules/luci.sys.init.html">luci.sys.init</a>
77         </li>
78
79         <li>
80                 <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
81         </li>
82
83         <li>
84                 <a href="../modules/luci.sys.net.html">luci.sys.net</a>
85         </li>
86
87         <li>
88                 <a href="../modules/luci.sys.process.html">luci.sys.process</a>
89         </li>
90
91         <li>
92                 <a href="../modules/luci.sys.user.html">luci.sys.user</a>
93         </li>
94
95         <li>
96                 <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
97         </li>
98
99         <li>
100                 <a href="../modules/nixio.html">nixio</a>
101         </li>
102
103         <li>
104                 <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
105         </li>
106
107         <li>
108                 <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
109         </li>
110
111         <li>
112                 <a href="../modules/nixio.File.html">nixio.File</a>
113         </li>
114
115         <li>
116                 <a href="../modules/nixio.README.html">nixio.README</a>
117         </li>
118
119         <li>
120                 <a href="../modules/nixio.Socket.html">nixio.Socket</a>
121         </li>
122
123         <li>
124                 <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
125         </li>
126
127         <li>
128                 <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
129         </li>
130
131         <li>
132                 <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
133         </li>
134
135         <li>
136                 <a href="../modules/nixio.bin.html">nixio.bin</a>
137         </li>
138
139         <li>
140                 <a href="../modules/nixio.bit.html">nixio.bit</a>
141         </li>
142
143         <li>
144                 <a href="../modules/nixio.crypto.html">nixio.crypto</a>
145         </li>
146
147         <li>
148                 <a href="../modules/nixio.fs.html">nixio.fs</a>
149         </li>
150
151 </ul>
152
153
154
155 <!-- File list -->
156
157
158
159
160
161
162
163 </div><!-- id="navigation" -->
164
165 <div id="content">
166
167 <h1>Class <code>luci.http.protocol</code></h1>
168
169 <p></p>
170
171
172
173
174
175
176
177 <h2>Functions</h2>
178 <table class="function_list">
179
180         <tr>
181         <td class="name" nowrap><a href="#header_source">header_source</a>&nbsp;(sock)</td>
182         <td class="summary">
183  
184 Creates a ltn12 source from the given socket.</td>
185         </tr>
186
187         <tr>
188         <td class="name" nowrap><a href="#mimedecode_message_body">mimedecode_message_body</a>&nbsp;(src, msg, filecb)</td>
189         <td class="summary">
190  
191 Decode a mime encoded http message body with multipart/form-data 
192  
193 Content-Type.</td>
194         </tr>
195
196         <tr>
197         <td class="name" nowrap><a href="#parse_message_body">parse_message_body</a>&nbsp;(src, msg, filecb)</td>
198         <td class="summary">
199  
200 Try to extract and decode a http message body from the given ltn12 source.</td>
201         </tr>
202
203         <tr>
204         <td class="name" nowrap><a href="#parse_message_header">parse_message_header</a>&nbsp;(src)</td>
205         <td class="summary">
206  
207 Try to extract an http message header including information like protocol 
208  
209 version, message headers and resulting CGI environment variables from the 
210 given ltn12 source.</td>
211         </tr>
212
213         <tr>
214         <td class="name" nowrap><a href="#urldecode">urldecode</a>&nbsp;(str, no_plus)</td>
215         <td class="summary">
216  
217 Decode an urlencoded string - optionally without decoding 
218  
219 the "+" sign to " " - and return the decoded string.</td>
220         </tr>
221
222         <tr>
223         <td class="name" nowrap><a href="#urldecode_message_body">urldecode_message_body</a>&nbsp;(src, msg)</td>
224         <td class="summary">
225  
226 Decode an urlencoded http message body with application/x-www-urlencoded 
227  
228 Content-Type.</td>
229         </tr>
230
231         <tr>
232         <td class="name" nowrap><a href="#urldecode_params">urldecode_params</a>&nbsp;(url, tbl)</td>
233         <td class="summary">
234  
235 Extract and split urlencoded data pairs, separated bei either "&" or ";" 
236  
237 from given url or string.</td>
238         </tr>
239
240         <tr>
241         <td class="name" nowrap><a href="#urlencode">urlencode</a>&nbsp;(str)</td>
242         <td class="summary">
243  
244 Encode given string to x-www-urlencoded format.</td>
245         </tr>
246
247         <tr>
248         <td class="name" nowrap><a href="#urlencode_params">urlencode_params</a>&nbsp;(tbl)</td>
249         <td class="summary">
250  
251 Encode each key-value-pair in given table to x-www-urlencoded format, 
252  
253 separated by "&".</td>
254         </tr>
255
256 </table>
257
258
259
260
261
262
263 <br/>
264 <br/>
265
266
267 <h2><a name="functions"></a>Functions</h2>
268 <dl class="function">
269
270
271
272 <dt><a name="header_source"></a><strong>header_source</strong>&nbsp;(sock)</dt>
273 <dd>
274
275  
276 Creates a ltn12 source from the given socket. The source will return it's 
277  
278 data line by line with the trailing \r\n stripped of.
279
280
281 <h3>Parameters</h3>
282 <ul>
283         
284         <li>
285           sock: Readable network socket
286         </li>
287         
288 </ul>
289
290
291
292
293
294
295 <h3>Return value:</h3>
296 Ltn12 source function
297
298
299
300 </dd>
301
302
303
304
305 <dt><a name="mimedecode_message_body"></a><strong>mimedecode_message_body</strong>&nbsp;(src, msg, filecb)</dt>
306 <dd>
307
308  
309 Decode a mime encoded http message body with multipart/form-data 
310  
311 Content-Type. Stores all extracted data associated with its parameter name 
312 in the params table withing the given message object. Multiple parameter 
313 values are stored as tables, ordinary ones as strings. 
314 If an optional file callback function is given then it is feeded with the 
315 file contents chunk by chunk and only the extracted file name is stored 
316 within the params table. The callback function will be called subsequently 
317 with three arguments: 
318  o Table containing decoded (name, file) and raw (headers) mime header data 
319  o String value containing a chunk of the file data 
320  o Boolean which indicates wheather the current chunk is the last one (eof)
321
322
323 <h3>Parameters</h3>
324 <ul>
325         
326         <li>
327           src: Ltn12 source function
328         </li>
329         
330         <li>
331           msg: HTTP message object
332         </li>
333         
334         <li>
335           filecb: File callback function (optional)
336         </li>
337         
338 </ul>
339
340
341
342
343
344
345 <h3>Return values:</h3>
346 <ol>
347         
348         <li>Value indicating successful operation (not nil means "ok")
349         
350         <li>String containing the error if unsuccessful
351         
352 </ol>
353
354
355
356 <h3>See also:</h3>
357 <ul>
358         
359         <li><a href="#parse_message_header">
360                 parse_message_header
361         </a>
362         
363 </ul>
364
365 </dd>
366
367
368
369
370 <dt><a name="parse_message_body"></a><strong>parse_message_body</strong>&nbsp;(src, msg, filecb)</dt>
371 <dd>
372
373  
374 Try to extract and decode a http message body from the given ltn12 source. 
375  
376 This function will examine the Content-Type within the given message object 
377 to select the appropriate content decoder. 
378 Currently the application/x-www-urlencoded and application/form-data 
379 mime types are supported. If the encountered content encoding can't be 
380 handled then the whole message body will be stored unaltered as "content" 
381 property within the given message object.
382
383
384 <h3>Parameters</h3>
385 <ul>
386         
387         <li>
388           src: Ltn12 source function
389         </li>
390         
391         <li>
392           msg: HTTP message object
393         </li>
394         
395         <li>
396           filecb: File data callback (optional, see mimedecode_message_body())
397         </li>
398         
399 </ul>
400
401
402
403
404
405
406 <h3>Return values:</h3>
407 <ol>
408         
409         <li>Value indicating successful operation (not nil means "ok")
410         
411         <li>String containing the error if unsuccessful
412         
413 </ol>
414
415
416
417 <h3>See also:</h3>
418 <ul>
419         
420         <li><a href="#parse_message_header">
421                 parse_message_header
422         </a>
423         
424 </ul>
425
426 </dd>
427
428
429
430
431 <dt><a name="parse_message_header"></a><strong>parse_message_header</strong>&nbsp;(src)</dt>
432 <dd>
433
434  
435 Try to extract an http message header including information like protocol 
436  
437 version, message headers and resulting CGI environment variables from the 
438 given ltn12 source.
439
440
441 <h3>Parameters</h3>
442 <ul>
443         
444         <li>
445           src: Ltn12 source function
446         </li>
447         
448 </ul>
449
450
451
452
453
454
455 <h3>Return value:</h3>
456 HTTP message object
457
458
459
460 <h3>See also:</h3>
461 <ul>
462         
463         <li><a href="#parse_message_body">
464                 parse_message_body
465         </a>
466         
467 </ul>
468
469 </dd>
470
471
472
473
474 <dt><a name="urldecode"></a><strong>urldecode</strong>&nbsp;(str, no_plus)</dt>
475 <dd>
476
477  
478 Decode an urlencoded string - optionally without decoding 
479  
480 the "+" sign to " " - and return the decoded string.
481
482
483 <h3>Parameters</h3>
484 <ul>
485         
486         <li>
487           str: Input string in x-www-urlencoded format
488         </li>
489         
490         <li>
491           no_plus: Don't decode "+" signs to spaces
492         </li>
493         
494 </ul>
495
496
497
498
499
500
501 <h3>Return value:</h3>
502 The decoded string
503
504
505
506 <h3>See also:</h3>
507 <ul>
508         
509         <li><a href="#urlencode">
510                 urlencode
511         </a>
512         
513 </ul>
514
515 </dd>
516
517
518
519
520 <dt><a name="urldecode_message_body"></a><strong>urldecode_message_body</strong>&nbsp;(src, msg)</dt>
521 <dd>
522
523  
524 Decode an urlencoded http message body with application/x-www-urlencoded 
525  
526 Content-Type. Stores all extracted data associated with its parameter name 
527 in the params table withing the given message object. Multiple parameter 
528 values are stored as tables, ordinary ones as strings.
529
530
531 <h3>Parameters</h3>
532 <ul>
533         
534         <li>
535           src: Ltn12 source function
536         </li>
537         
538         <li>
539           msg: HTTP message object
540         </li>
541         
542 </ul>
543
544
545
546
547
548
549 <h3>Return values:</h3>
550 <ol>
551         
552         <li>Value indicating successful operation (not nil means "ok")
553         
554         <li>String containing the error if unsuccessful
555         
556 </ol>
557
558
559
560 <h3>See also:</h3>
561 <ul>
562         
563         <li><a href="#parse_message_header">
564                 parse_message_header
565         </a>
566         
567 </ul>
568
569 </dd>
570
571
572
573
574 <dt><a name="urldecode_params"></a><strong>urldecode_params</strong>&nbsp;(url, tbl)</dt>
575 <dd>
576
577  
578 Extract and split urlencoded data pairs, separated bei either "&" or ";" 
579  
580 from given url or string. Returns a table with urldecoded values. 
581 Simple parameters are stored as string values associated with the parameter 
582 name within the table. Parameters with multiple values are stored as array 
583 containing the corresponding values.
584
585
586 <h3>Parameters</h3>
587 <ul>
588         
589         <li>
590           url: The url or string which contains x-www-urlencoded form data
591         </li>
592         
593         <li>
594           tbl: Use the given table for storing values (optional)
595         </li>
596         
597 </ul>
598
599
600
601
602
603
604 <h3>Return value:</h3>
605 Table containing the urldecoded parameters
606
607
608
609 <h3>See also:</h3>
610 <ul>
611         
612         <li><a href="#urlencode_params">
613                 urlencode_params
614         </a>
615         
616 </ul>
617
618 </dd>
619
620
621
622
623 <dt><a name="urlencode"></a><strong>urlencode</strong>&nbsp;(str)</dt>
624 <dd>
625
626  
627 Encode given string to x-www-urlencoded format. 
628
629
630
631 <h3>Parameters</h3>
632 <ul>
633         
634         <li>
635           str: String to encode
636         </li>
637         
638 </ul>
639
640
641
642
643
644
645 <h3>Return value:</h3>
646 String containing the encoded data
647
648
649
650 <h3>See also:</h3>
651 <ul>
652         
653         <li><a href="#urldecode">
654                 urldecode
655         </a>
656         
657 </ul>
658
659 </dd>
660
661
662
663
664 <dt><a name="urlencode_params"></a><strong>urlencode_params</strong>&nbsp;(tbl)</dt>
665 <dd>
666
667  
668 Encode each key-value-pair in given table to x-www-urlencoded format, 
669  
670 separated by "&". Tables are encoded as parameters with multiple values by 
671 repeating the parameter name with each value.
672
673
674 <h3>Parameters</h3>
675 <ul>
676         
677         <li>
678           tbl: Table with the values
679         </li>
680         
681 </ul>
682
683
684
685
686
687
688 <h3>Return value:</h3>
689 String containing encoded values
690
691
692
693 <h3>See also:</h3>
694 <ul>
695         
696         <li><a href="#urldecode_params">
697                 urldecode_params
698         </a>
699         
700 </ul>
701
702 </dd>
703
704
705 </dl>
706
707
708
709
710
711 </div> <!-- id="content" -->
712
713 </div> <!-- id="main" -->
714
715 <div id="about">
716         <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>
717 </div> <!-- id="about" -->
718
719 </div> <!-- id="container" -->
720 </body>
721 </html>