2
0

luci.http.html 17 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  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. <body>
  10. <div id="container">
  11. <div id="product">
  12. <div id="product_logo"></div>
  13. <div id="product_name"><big><b></b></big></div>
  14. <div id="product_description"></div>
  15. </div> <!-- id="product" -->
  16. <div id="main">
  17. <div id="navigation">
  18. <h1>LuaDoc</h1>
  19. <ul>
  20. <li><a href="../index.html">Index</a></li>
  21. </ul>
  22. <!-- Module list -->
  23. <h1>Modules</h1>
  24. <ul>
  25. <li>
  26. <a href="../modules/luci.dispatcher.html">luci.dispatcher</a>
  27. </li>
  28. <li><strong>luci.http</strong></li>
  29. <li>
  30. <a href="../modules/luci.http.conditionals.html">luci.http.conditionals</a>
  31. </li>
  32. <li>
  33. <a href="../modules/luci.http.date.html">luci.http.date</a>
  34. </li>
  35. <li>
  36. <a href="../modules/luci.http.mime.html">luci.http.mime</a>
  37. </li>
  38. <li>
  39. <a href="../modules/luci.i18n.html">luci.i18n</a>
  40. </li>
  41. <li>
  42. <a href="../modules/luci.ip.html">luci.ip</a>
  43. </li>
  44. <li>
  45. <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
  46. </li>
  47. <li>
  48. <a href="../modules/luci.json.html">luci.json</a>
  49. </li>
  50. <li>
  51. <a href="../modules/luci.jsonc.html">luci.jsonc</a>
  52. </li>
  53. <li>
  54. <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
  55. </li>
  56. <li>
  57. <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
  58. </li>
  59. <li>
  60. <a href="../modules/luci.model.uci.html">luci.model.uci</a>
  61. </li>
  62. <li>
  63. <a href="../modules/luci.rpcc.html">luci.rpcc</a>
  64. </li>
  65. <li>
  66. <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
  67. </li>
  68. <li>
  69. <a href="../modules/luci.sys.html">luci.sys</a>
  70. </li>
  71. <li>
  72. <a href="../modules/luci.sys.init.html">luci.sys.init</a>
  73. </li>
  74. <li>
  75. <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
  76. </li>
  77. <li>
  78. <a href="../modules/luci.sys.net.html">luci.sys.net</a>
  79. </li>
  80. <li>
  81. <a href="../modules/luci.sys.process.html">luci.sys.process</a>
  82. </li>
  83. <li>
  84. <a href="../modules/luci.sys.user.html">luci.sys.user</a>
  85. </li>
  86. <li>
  87. <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
  88. </li>
  89. <li>
  90. <a href="../modules/luci.util.html">luci.util</a>
  91. </li>
  92. <li>
  93. <a href="../modules/luci.xml.html">luci.xml</a>
  94. </li>
  95. <li>
  96. <a href="../modules/nixio.html">nixio</a>
  97. </li>
  98. <li>
  99. <a href="../modules/nixio.CHANGELOG.html">nixio.CHANGELOG</a>
  100. </li>
  101. <li>
  102. <a href="../modules/nixio.CryptoHash.html">nixio.CryptoHash</a>
  103. </li>
  104. <li>
  105. <a href="../modules/nixio.File.html">nixio.File</a>
  106. </li>
  107. <li>
  108. <a href="../modules/nixio.README.html">nixio.README</a>
  109. </li>
  110. <li>
  111. <a href="../modules/nixio.Socket.html">nixio.Socket</a>
  112. </li>
  113. <li>
  114. <a href="../modules/nixio.TLSContext.html">nixio.TLSContext</a>
  115. </li>
  116. <li>
  117. <a href="../modules/nixio.TLSSocket.html">nixio.TLSSocket</a>
  118. </li>
  119. <li>
  120. <a href="../modules/nixio.UnifiedIO.html">nixio.UnifiedIO</a>
  121. </li>
  122. <li>
  123. <a href="../modules/nixio.bin.html">nixio.bin</a>
  124. </li>
  125. <li>
  126. <a href="../modules/nixio.bit.html">nixio.bit</a>
  127. </li>
  128. <li>
  129. <a href="../modules/nixio.crypto.html">nixio.crypto</a>
  130. </li>
  131. <li>
  132. <a href="../modules/nixio.fs.html">nixio.fs</a>
  133. </li>
  134. </ul>
  135. <!-- File list -->
  136. </div><!-- id="navigation" -->
  137. <div id="content">
  138. <h1>Class <code>luci.http</code></h1>
  139. <p></p>
  140. <h2>Functions</h2>
  141. <table class="function_list">
  142. <tr>
  143. <td class="name" nowrap><a href="#build_querystring">build_querystring</a>&nbsp;(table)</td>
  144. <td class="summary">
  145. Create a querystring out of a table of key - value pairs.</td>
  146. </tr>
  147. <tr>
  148. <td class="name" nowrap><a href="#close">close</a>&nbsp;()</td>
  149. <td class="summary">
  150. Close the HTTP-Connection.</td>
  151. </tr>
  152. <tr>
  153. <td class="name" nowrap><a href="#content">content</a>&nbsp;()</td>
  154. <td class="summary">
  155. Return the request content if the request was of unknown type.</td>
  156. </tr>
  157. <tr>
  158. <td class="name" nowrap><a href="#formvalue">formvalue</a>&nbsp;(name, noparse)</td>
  159. <td class="summary">
  160. Get a certain HTTP input value or a table of all input values.</td>
  161. </tr>
  162. <tr>
  163. <td class="name" nowrap><a href="#formvaluetable">formvaluetable</a>&nbsp;(prefix)</td>
  164. <td class="summary">
  165. Get a table of all HTTP input values with a certain prefix.</td>
  166. </tr>
  167. <tr>
  168. <td class="name" nowrap><a href="#getcookie">getcookie</a>&nbsp;(name)</td>
  169. <td class="summary">
  170. Get the value of a certain HTTP-Cookie.</td>
  171. </tr>
  172. <tr>
  173. <td class="name" nowrap><a href="#getenv">getenv</a>&nbsp;(name)</td>
  174. <td class="summary">
  175. Get the value of a certain HTTP environment variable
  176. or the environment table itself.</td>
  177. </tr>
  178. <tr>
  179. <td class="name" nowrap><a href="#header">header</a>&nbsp;(key, value)</td>
  180. <td class="summary">
  181. Send a HTTP-Header.</td>
  182. </tr>
  183. <tr>
  184. <td class="name" nowrap><a href="#mimedecode_message_body">mimedecode_message_body</a>&nbsp;(src, msg, filecb)</td>
  185. <td class="summary">
  186. Decode a mime encoded http message body with multipart/form-data Content-Type.</td>
  187. </tr>
  188. <tr>
  189. <td class="name" nowrap><a href="#parse_message_body">parse_message_body</a>&nbsp;(src, msg, filecb)</td>
  190. <td class="summary">
  191. Try to extract and decode a http message body from the given ltn12 source.</td>
  192. </tr>
  193. <tr>
  194. <td class="name" nowrap><a href="#prepare_content">prepare_content</a>&nbsp;(mime)</td>
  195. <td class="summary">
  196. Set the mime type of following content data.</td>
  197. </tr>
  198. <tr>
  199. <td class="name" nowrap><a href="#redirect">redirect</a>&nbsp;(url)</td>
  200. <td class="summary">
  201. Redirects the client to a new URL and closes the connection.</td>
  202. </tr>
  203. <tr>
  204. <td class="name" nowrap><a href="#setfilehandler">setfilehandler</a>&nbsp;(callback)</td>
  205. <td class="summary">
  206. Set a handler function for incoming user file uploads.</td>
  207. </tr>
  208. <tr>
  209. <td class="name" nowrap><a href="#source">source</a>&nbsp;()</td>
  210. <td class="summary">
  211. Get the RAW HTTP input source
  212. </td>
  213. </tr>
  214. <tr>
  215. <td class="name" nowrap><a href="#splice">splice</a>&nbsp;(fp, size)</td>
  216. <td class="summary">
  217. Splice data from a filedescriptor to the client.</td>
  218. </tr>
  219. <tr>
  220. <td class="name" nowrap><a href="#status">status</a>&nbsp;(code, message)</td>
  221. <td class="summary">
  222. Set the HTTP status code and status message.</td>
  223. </tr>
  224. <tr>
  225. <td class="name" nowrap><a href="#urldecode">urldecode</a>&nbsp;(str, no_plus)</td>
  226. <td class="summary">
  227. Return the URL-decoded equivalent of a string.</td>
  228. </tr>
  229. <tr>
  230. <td class="name" nowrap><a href="#urldecode_message_body">urldecode_message_body</a>&nbsp;(src, msg)</td>
  231. <td class="summary">
  232. Decode an urlencoded http message body with application/x-www-urlencoded
  233. Content-Type.</td>
  234. </tr>
  235. <tr>
  236. <td class="name" nowrap><a href="#urldecode_params">urldecode_params</a>&nbsp;(url, tbl)</td>
  237. <td class="summary">
  238. Extract and split urlencoded data pairs, separated bei either "&" or ";"
  239. from given url or string.</td>
  240. </tr>
  241. <tr>
  242. <td class="name" nowrap><a href="#urlencode">urlencode</a>&nbsp;(str)</td>
  243. <td class="summary">
  244. Return the URL-encoded equivalent of a string.</td>
  245. </tr>
  246. <tr>
  247. <td class="name" nowrap><a href="#urlencode_params">urlencode_params</a>&nbsp;(tbl)</td>
  248. <td class="summary">
  249. Encode each key-value-pair in given table to x-www-urlencoded format,
  250. separated by "&".</td>
  251. </tr>
  252. <tr>
  253. <td class="name" nowrap><a href="#write">write</a>&nbsp;(content, src_err)</td>
  254. <td class="summary">
  255. Send a chunk of content data to the client.</td>
  256. </tr>
  257. <tr>
  258. <td class="name" nowrap><a href="#write_json">write_json</a>&nbsp;(data)</td>
  259. <td class="summary">
  260. Send the given data as JSON encoded string.</td>
  261. </tr>
  262. </table>
  263. <br/>
  264. <br/>
  265. <h2><a name="functions"></a>Functions</h2>
  266. <dl class="function">
  267. <dt><a name="build_querystring"></a><strong>build_querystring</strong>&nbsp;(table)</dt>
  268. <dd>
  269. Create a querystring out of a table of key - value pairs.
  270. <h3>Parameters</h3>
  271. <ul>
  272. <li>
  273. table: Query string source table
  274. </li>
  275. </ul>
  276. <h3>Return value:</h3>
  277. Encoded HTTP query string
  278. </dd>
  279. <dt><a name="close"></a><strong>close</strong>&nbsp;()</dt>
  280. <dd>
  281. Close the HTTP-Connection.
  282. </dd>
  283. <dt><a name="content"></a><strong>content</strong>&nbsp;()</dt>
  284. <dd>
  285. Return the request content if the request was of unknown type.
  286. <h3>Return values:</h3>
  287. <ol>
  288. <li>HTTP request body
  289. <li>HTTP request body length
  290. </ol>
  291. </dd>
  292. <dt><a name="formvalue"></a><strong>formvalue</strong>&nbsp;(name, noparse)</dt>
  293. <dd>
  294. Get a certain HTTP input value or a table of all input values.
  295. <h3>Parameters</h3>
  296. <ul>
  297. <li>
  298. name: Name of the GET or POST variable to fetch
  299. </li>
  300. <li>
  301. noparse: Don't parse POST data before getting the value
  302. </li>
  303. </ul>
  304. <h3>Return value:</h3>
  305. HTTP input value or table of all input value
  306. </dd>
  307. <dt><a name="formvaluetable"></a><strong>formvaluetable</strong>&nbsp;(prefix)</dt>
  308. <dd>
  309. Get a table of all HTTP input values with a certain prefix.
  310. <h3>Parameters</h3>
  311. <ul>
  312. <li>
  313. prefix: Prefix
  314. </li>
  315. </ul>
  316. <h3>Return value:</h3>
  317. Table of all HTTP input values with given prefix
  318. </dd>
  319. <dt><a name="getcookie"></a><strong>getcookie</strong>&nbsp;(name)</dt>
  320. <dd>
  321. Get the value of a certain HTTP-Cookie.
  322. <h3>Parameters</h3>
  323. <ul>
  324. <li>
  325. name: Cookie Name
  326. </li>
  327. </ul>
  328. <h3>Return value:</h3>
  329. String containing cookie data
  330. </dd>
  331. <dt><a name="getenv"></a><strong>getenv</strong>&nbsp;(name)</dt>
  332. <dd>
  333. Get the value of a certain HTTP environment variable
  334. or the environment table itself.
  335. <h3>Parameters</h3>
  336. <ul>
  337. <li>
  338. name: Environment variable
  339. </li>
  340. </ul>
  341. <h3>Return value:</h3>
  342. HTTP environment value or environment table
  343. </dd>
  344. <dt><a name="header"></a><strong>header</strong>&nbsp;(key, value)</dt>
  345. <dd>
  346. Send a HTTP-Header.
  347. <h3>Parameters</h3>
  348. <ul>
  349. <li>
  350. key: Header key
  351. </li>
  352. <li>
  353. value: Header value
  354. </li>
  355. </ul>
  356. </dd>
  357. <dt><a name="mimedecode_message_body"></a><strong>mimedecode_message_body</strong>&nbsp;(src, msg, filecb)</dt>
  358. <dd>
  359. Decode a mime encoded http message body with multipart/form-data Content-Type.
  360. Stores all extracted data associated with its parameter name
  361. in the params table within the given message object. Multiple parameter
  362. values are stored as tables, ordinary ones as strings.
  363. If an optional file callback function is given then it is fed with the
  364. file contents chunk by chunk and only the extracted file name is stored
  365. within the params table. The callback function will be called subsequently
  366. with three arguments:
  367. o Table containing decoded (name, file) and raw (headers) mime header data
  368. o String value containing a chunk of the file data
  369. o Boolean which indicates whether the current chunk is the last one (eof)
  370. <h3>Parameters</h3>
  371. <ul>
  372. <li>
  373. src: Ltn12 source function
  374. </li>
  375. <li>
  376. msg: HTTP message object
  377. </li>
  378. <li>
  379. filecb: File callback function (optional)
  380. </li>
  381. </ul>
  382. <h3>Return values:</h3>
  383. <ol>
  384. <li>Value indicating successful operation (not nil means "ok")
  385. <li>String containing the error if unsuccessful
  386. </ol>
  387. <h3>See also:</h3>
  388. <ul>
  389. <li><a href="">
  390. parse_message_header
  391. </a>
  392. </ul>
  393. </dd>
  394. <dt><a name="parse_message_body"></a><strong>parse_message_body</strong>&nbsp;(src, msg, filecb)</dt>
  395. <dd>
  396. Try to extract and decode a http message body from the given ltn12 source.
  397. This function will examine the Content-Type within the given message object
  398. to select the appropriate content decoder.
  399. Currently the application/x-www-urlencoded and application/form-data
  400. mime types are supported. If the encountered content encoding can't be
  401. handled then the whole message body will be stored unaltered as "content"
  402. property within the given message object.
  403. <h3>Parameters</h3>
  404. <ul>
  405. <li>
  406. src: Ltn12 source function
  407. </li>
  408. <li>
  409. msg: HTTP message object
  410. </li>
  411. <li>
  412. filecb: File data callback (optional, see mimedecode_message_body())
  413. </li>
  414. </ul>
  415. <h3>Return values:</h3>
  416. <ol>
  417. <li>Value indicating successful operation (not nil means "ok")
  418. <li>String containing the error if unsuccessful
  419. </ol>
  420. <h3>See also:</h3>
  421. <ul>
  422. <li><a href="">
  423. parse_message_header
  424. </a>
  425. </ul>
  426. </dd>
  427. <dt><a name="prepare_content"></a><strong>prepare_content</strong>&nbsp;(mime)</dt>
  428. <dd>
  429. Set the mime type of following content data.
  430. <h3>Parameters</h3>
  431. <ul>
  432. <li>
  433. mime: Mimetype of following content
  434. </li>
  435. </ul>
  436. </dd>
  437. <dt><a name="redirect"></a><strong>redirect</strong>&nbsp;(url)</dt>
  438. <dd>
  439. Redirects the client to a new URL and closes the connection.
  440. <h3>Parameters</h3>
  441. <ul>
  442. <li>
  443. url: Target URL
  444. </li>
  445. </ul>
  446. </dd>
  447. <dt><a name="setfilehandler"></a><strong>setfilehandler</strong>&nbsp;(callback)</dt>
  448. <dd>
  449. Set a handler function for incoming user file uploads.
  450. <h3>Parameters</h3>
  451. <ul>
  452. <li>
  453. callback: Handler function
  454. </li>
  455. </ul>
  456. </dd>
  457. <dt><a name="source"></a><strong>source</strong>&nbsp;()</dt>
  458. <dd>
  459. Get the RAW HTTP input source
  460. <h3>Return value:</h3>
  461. HTTP LTN12 source
  462. </dd>
  463. <dt><a name="splice"></a><strong>splice</strong>&nbsp;(fp, size)</dt>
  464. <dd>
  465. Splice data from a filedescriptor to the client.
  466. <h3>Parameters</h3>
  467. <ul>
  468. <li>
  469. fp: File descriptor
  470. </li>
  471. <li>
  472. size: Bytes to splice (optional)
  473. </li>
  474. </ul>
  475. </dd>
  476. <dt><a name="status"></a><strong>status</strong>&nbsp;(code, message)</dt>
  477. <dd>
  478. Set the HTTP status code and status message.
  479. <h3>Parameters</h3>
  480. <ul>
  481. <li>
  482. code: Status code
  483. </li>
  484. <li>
  485. message: Status message
  486. </li>
  487. </ul>
  488. </dd>
  489. <dt><a name="urldecode"></a><strong>urldecode</strong>&nbsp;(str, no_plus)</dt>
  490. <dd>
  491. Return the URL-decoded equivalent of a string.
  492. <h3>Parameters</h3>
  493. <ul>
  494. <li>
  495. str: URL-encoded string
  496. </li>
  497. <li>
  498. no_plus: Don't decode + to " "
  499. </li>
  500. </ul>
  501. <h3>Return value:</h3>
  502. URL-decoded string
  503. <h3>See also:</h3>
  504. <ul>
  505. <li><a href="#urlencode">
  506. urlencode
  507. </a>
  508. </ul>
  509. </dd>
  510. <dt><a name="urldecode_message_body"></a><strong>urldecode_message_body</strong>&nbsp;(src, msg)</dt>
  511. <dd>
  512. Decode an urlencoded http message body with application/x-www-urlencoded
  513. Content-Type.
  514. Stores all extracted data associated with its parameter name in the params
  515. table within the given message object. Multiple parameter values are stored
  516. as tables, ordinary ones as strings.
  517. <h3>Parameters</h3>
  518. <ul>
  519. <li>
  520. src: Ltn12 source function
  521. </li>
  522. <li>
  523. msg: HTTP message object
  524. </li>
  525. </ul>
  526. <h3>Return values:</h3>
  527. <ol>
  528. <li>Value indicating successful operation (not nil means "ok")
  529. <li>String containing the error if unsuccessful
  530. </ol>
  531. <h3>See also:</h3>
  532. <ul>
  533. <li><a href="">
  534. parse_message_header
  535. </a>
  536. </ul>
  537. </dd>
  538. <dt><a name="urldecode_params"></a><strong>urldecode_params</strong>&nbsp;(url, tbl)</dt>
  539. <dd>
  540. Extract and split urlencoded data pairs, separated bei either "&" or ";"
  541. from given url or string. Returns a table with urldecoded values.
  542. Simple parameters are stored as string values associated with the parameter
  543. name within the table. Parameters with multiple values are stored as array
  544. containing the corresponding values.
  545. <h3>Parameters</h3>
  546. <ul>
  547. <li>
  548. url: The url or string which contains x-www-urlencoded form data
  549. </li>
  550. <li>
  551. tbl: Use the given table for storing values (optional)
  552. </li>
  553. </ul>
  554. <h3>Return value:</h3>
  555. Table containing the urldecoded parameters
  556. <h3>See also:</h3>
  557. <ul>
  558. <li><a href="#urlencode_params">
  559. urlencode_params
  560. </a>
  561. </ul>
  562. </dd>
  563. <dt><a name="urlencode"></a><strong>urlencode</strong>&nbsp;(str)</dt>
  564. <dd>
  565. Return the URL-encoded equivalent of a string.
  566. <h3>Parameters</h3>
  567. <ul>
  568. <li>
  569. str: Source string
  570. </li>
  571. </ul>
  572. <h3>Return value:</h3>
  573. URL-encoded string
  574. <h3>See also:</h3>
  575. <ul>
  576. <li><a href="#urldecode">
  577. urldecode
  578. </a>
  579. </ul>
  580. </dd>
  581. <dt><a name="urlencode_params"></a><strong>urlencode_params</strong>&nbsp;(tbl)</dt>
  582. <dd>
  583. Encode each key-value-pair in given table to x-www-urlencoded format,
  584. separated by "&".
  585. Tables are encoded as parameters with multiple values by repeating the
  586. parameter name with each value.
  587. <h3>Parameters</h3>
  588. <ul>
  589. <li>
  590. tbl: Table with the values
  591. </li>
  592. </ul>
  593. <h3>Return value:</h3>
  594. String containing encoded values
  595. <h3>See also:</h3>
  596. <ul>
  597. <li><a href="#urldecode_params">
  598. urldecode_params
  599. </a>
  600. </ul>
  601. </dd>
  602. <dt><a name="write"></a><strong>write</strong>&nbsp;(content, src_err)</dt>
  603. <dd>
  604. Send a chunk of content data to the client.
  605. This function is as a valid LTN12 sink.
  606. If the content chunk is nil this function will automatically invoke close.
  607. <h3>Parameters</h3>
  608. <ul>
  609. <li>
  610. content: Content chunk
  611. </li>
  612. <li>
  613. src_err: Error object from source (optional)
  614. </li>
  615. </ul>
  616. <h3>See also:</h3>
  617. <ul>
  618. <li><a href="#close">
  619. close
  620. </a>
  621. </ul>
  622. </dd>
  623. <dt><a name="write_json"></a><strong>write_json</strong>&nbsp;(data)</dt>
  624. <dd>
  625. Send the given data as JSON encoded string.
  626. <h3>Parameters</h3>
  627. <ul>
  628. <li>
  629. data: Data to send
  630. </li>
  631. </ul>
  632. </dd>
  633. </dl>
  634. </div> <!-- id="content" -->
  635. </div> <!-- id="main" -->
  636. <div id="about">
  637. <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>
  638. </div> <!-- id="about" -->
  639. </div> <!-- id="container" -->
  640. </body>
  641. </html>