1
0

luci.http.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  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.protocol.html">luci.http.protocol</a>
  31. </li>
  32. <li>
  33. <a href="../modules/luci.http.protocol.conditionals.html">luci.http.protocol.conditionals</a>
  34. </li>
  35. <li>
  36. <a href="../modules/luci.http.protocol.date.html">luci.http.protocol.date</a>
  37. </li>
  38. <li>
  39. <a href="../modules/luci.http.protocol.mime.html">luci.http.protocol.mime</a>
  40. </li>
  41. <li>
  42. <a href="../modules/luci.i18n.html">luci.i18n</a>
  43. </li>
  44. <li>
  45. <a href="../modules/luci.ip.html">luci.ip</a>
  46. </li>
  47. <li>
  48. <a href="../modules/luci.ip.cidr.html">luci.ip.cidr</a>
  49. </li>
  50. <li>
  51. <a href="../modules/luci.json.html">luci.json</a>
  52. </li>
  53. <li>
  54. <a href="../modules/luci.jsonc.html">luci.jsonc</a>
  55. </li>
  56. <li>
  57. <a href="../modules/luci.jsonc.parser.html">luci.jsonc.parser</a>
  58. </li>
  59. <li>
  60. <a href="../modules/luci.model.ipkg.html">luci.model.ipkg</a>
  61. </li>
  62. <li>
  63. <a href="../modules/luci.model.uci.html">luci.model.uci</a>
  64. </li>
  65. <li>
  66. <a href="../modules/luci.rpcc.html">luci.rpcc</a>
  67. </li>
  68. <li>
  69. <a href="../modules/luci.rpcc.ruci.html">luci.rpcc.ruci</a>
  70. </li>
  71. <li>
  72. <a href="../modules/luci.sys.html">luci.sys</a>
  73. </li>
  74. <li>
  75. <a href="../modules/luci.sys.init.html">luci.sys.init</a>
  76. </li>
  77. <li>
  78. <a href="../modules/luci.sys.iptparser.html">luci.sys.iptparser</a>
  79. </li>
  80. <li>
  81. <a href="../modules/luci.sys.net.html">luci.sys.net</a>
  82. </li>
  83. <li>
  84. <a href="../modules/luci.sys.process.html">luci.sys.process</a>
  85. </li>
  86. <li>
  87. <a href="../modules/luci.sys.user.html">luci.sys.user</a>
  88. </li>
  89. <li>
  90. <a href="../modules/luci.sys.wifi.html">luci.sys.wifi</a>
  91. </li>
  92. <li>
  93. <a href="../modules/luci.util.html">luci.util</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="#prepare_content">prepare_content</a>&nbsp;(mime)</td>
  185. <td class="summary">
  186. Set the mime type of following content data.</td>
  187. </tr>
  188. <tr>
  189. <td class="name" nowrap><a href="#redirect">redirect</a>&nbsp;(url)</td>
  190. <td class="summary">
  191. Redirects the client to a new URL and closes the connection.</td>
  192. </tr>
  193. <tr>
  194. <td class="name" nowrap><a href="#setfilehandler">setfilehandler</a>&nbsp;(callback)</td>
  195. <td class="summary">
  196. Set a handler function for incoming user file uploads.</td>
  197. </tr>
  198. <tr>
  199. <td class="name" nowrap><a href="#source">source</a>&nbsp;()</td>
  200. <td class="summary">
  201. Get the RAW HTTP input source
  202. </td>
  203. </tr>
  204. <tr>
  205. <td class="name" nowrap><a href="#splice">splice</a>&nbsp;(fp, size)</td>
  206. <td class="summary">
  207. Splice data from a filedescriptor to the client.</td>
  208. </tr>
  209. <tr>
  210. <td class="name" nowrap><a href="#status">status</a>&nbsp;(code, message)</td>
  211. <td class="summary">
  212. Set the HTTP status code and status message.</td>
  213. </tr>
  214. <tr>
  215. <td class="name" nowrap><a href="#write">write</a>&nbsp;(content, src_err)</td>
  216. <td class="summary">
  217. Send a chunk of content data to the client.</td>
  218. </tr>
  219. <tr>
  220. <td class="name" nowrap><a href="#write_json">write_json</a>&nbsp;(data)</td>
  221. <td class="summary">
  222. Send the given data as JSON encoded string.</td>
  223. </tr>
  224. </table>
  225. <br/>
  226. <br/>
  227. <h2><a name="functions"></a>Functions</h2>
  228. <dl class="function">
  229. <dt><a name="build_querystring"></a><strong>build_querystring</strong>&nbsp;(table)</dt>
  230. <dd>
  231. Create a querystring out of a table of key - value pairs.
  232. <h3>Parameters</h3>
  233. <ul>
  234. <li>
  235. table: Query string source table
  236. </li>
  237. </ul>
  238. <h3>Return value:</h3>
  239. Encoded HTTP query string
  240. </dd>
  241. <dt><a name="close"></a><strong>close</strong>&nbsp;()</dt>
  242. <dd>
  243. Close the HTTP-Connection.
  244. </dd>
  245. <dt><a name="content"></a><strong>content</strong>&nbsp;()</dt>
  246. <dd>
  247. Return the request content if the request was of unknown type.
  248. <h3>Return values:</h3>
  249. <ol>
  250. <li>HTTP request body
  251. <li>HTTP request body length
  252. </ol>
  253. </dd>
  254. <dt><a name="formvalue"></a><strong>formvalue</strong>&nbsp;(name, noparse)</dt>
  255. <dd>
  256. Get a certain HTTP input value or a table of all input values.
  257. <h3>Parameters</h3>
  258. <ul>
  259. <li>
  260. name: Name of the GET or POST variable to fetch
  261. </li>
  262. <li>
  263. noparse: Don't parse POST data before getting the value
  264. </li>
  265. </ul>
  266. <h3>Return value:</h3>
  267. HTTP input value or table of all input value
  268. </dd>
  269. <dt><a name="formvaluetable"></a><strong>formvaluetable</strong>&nbsp;(prefix)</dt>
  270. <dd>
  271. Get a table of all HTTP input values with a certain prefix.
  272. <h3>Parameters</h3>
  273. <ul>
  274. <li>
  275. prefix: Prefix
  276. </li>
  277. </ul>
  278. <h3>Return value:</h3>
  279. Table of all HTTP input values with given prefix
  280. </dd>
  281. <dt><a name="getcookie"></a><strong>getcookie</strong>&nbsp;(name)</dt>
  282. <dd>
  283. Get the value of a certain HTTP-Cookie.
  284. <h3>Parameters</h3>
  285. <ul>
  286. <li>
  287. name: Cookie Name
  288. </li>
  289. </ul>
  290. <h3>Return value:</h3>
  291. String containing cookie data
  292. </dd>
  293. <dt><a name="getenv"></a><strong>getenv</strong>&nbsp;(name)</dt>
  294. <dd>
  295. Get the value of a certain HTTP environment variable
  296. or the environment table itself.
  297. <h3>Parameters</h3>
  298. <ul>
  299. <li>
  300. name: Environment variable
  301. </li>
  302. </ul>
  303. <h3>Return value:</h3>
  304. HTTP environment value or environment table
  305. </dd>
  306. <dt><a name="header"></a><strong>header</strong>&nbsp;(key, value)</dt>
  307. <dd>
  308. Send a HTTP-Header.
  309. <h3>Parameters</h3>
  310. <ul>
  311. <li>
  312. key: Header key
  313. </li>
  314. <li>
  315. value: Header value
  316. </li>
  317. </ul>
  318. </dd>
  319. <dt><a name="prepare_content"></a><strong>prepare_content</strong>&nbsp;(mime)</dt>
  320. <dd>
  321. Set the mime type of following content data.
  322. <h3>Parameters</h3>
  323. <ul>
  324. <li>
  325. mime: Mimetype of following content
  326. </li>
  327. </ul>
  328. </dd>
  329. <dt><a name="redirect"></a><strong>redirect</strong>&nbsp;(url)</dt>
  330. <dd>
  331. Redirects the client to a new URL and closes the connection.
  332. <h3>Parameters</h3>
  333. <ul>
  334. <li>
  335. url: Target URL
  336. </li>
  337. </ul>
  338. </dd>
  339. <dt><a name="setfilehandler"></a><strong>setfilehandler</strong>&nbsp;(callback)</dt>
  340. <dd>
  341. Set a handler function for incoming user file uploads.
  342. <h3>Parameters</h3>
  343. <ul>
  344. <li>
  345. callback: Handler function
  346. </li>
  347. </ul>
  348. </dd>
  349. <dt><a name="source"></a><strong>source</strong>&nbsp;()</dt>
  350. <dd>
  351. Get the RAW HTTP input source
  352. <h3>Return value:</h3>
  353. HTTP LTN12 source
  354. </dd>
  355. <dt><a name="splice"></a><strong>splice</strong>&nbsp;(fp, size)</dt>
  356. <dd>
  357. Splice data from a filedescriptor to the client.
  358. <h3>Parameters</h3>
  359. <ul>
  360. <li>
  361. fp: File descriptor
  362. </li>
  363. <li>
  364. size: Bytes to splice (optional)
  365. </li>
  366. </ul>
  367. </dd>
  368. <dt><a name="status"></a><strong>status</strong>&nbsp;(code, message)</dt>
  369. <dd>
  370. Set the HTTP status code and status message.
  371. <h3>Parameters</h3>
  372. <ul>
  373. <li>
  374. code: Status code
  375. </li>
  376. <li>
  377. message: Status message
  378. </li>
  379. </ul>
  380. </dd>
  381. <dt><a name="write"></a><strong>write</strong>&nbsp;(content, src_err)</dt>
  382. <dd>
  383. Send a chunk of content data to the client.
  384. This function is as a valid LTN12 sink.
  385. If the content chunk is nil this function will automatically invoke close.
  386. <h3>Parameters</h3>
  387. <ul>
  388. <li>
  389. content: Content chunk
  390. </li>
  391. <li>
  392. src_err: Error object from source (optional)
  393. </li>
  394. </ul>
  395. <h3>See also:</h3>
  396. <ul>
  397. <li><a href="#close">
  398. close
  399. </a>
  400. </ul>
  401. </dd>
  402. <dt><a name="write_json"></a><strong>write_json</strong>&nbsp;(data)</dt>
  403. <dd>
  404. Send the given data as JSON encoded string.
  405. <h3>Parameters</h3>
  406. <ul>
  407. <li>
  408. data: Data to send
  409. </li>
  410. </ul>
  411. </dd>
  412. </dl>
  413. </div> <!-- id="content" -->
  414. </div> <!-- id="main" -->
  415. <div id="about">
  416. <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>
  417. </div> <!-- id="about" -->
  418. </div> <!-- id="container" -->
  419. </body>
  420. </html>