2 LuCI Web Framework high-level HTTP functions.
7 Close the HTTP-Connection.
14 Return the request content if the request was of unknown type.
18 @return HTTP request body
19 @return HTTP request body length
23 Get a certain HTTP input value or a table of all input values.
27 @param name Name of the GET or POST variable to fetch
28 @param noparse Don't parse POST data before getting the value
29 @return HTTP input value or table of all input value
33 Get a table of all HTTP input values with a certain prefix.
38 @return Table of all HTTP input values with given prefix
42 Get the value of a certain HTTP-Cookie.
46 @param name Cookie Name
47 @return String containing cookie data
51 Get the value of a certain HTTP environment variable
52 or the environment table itself.
56 @param name Environment variable
57 @return HTTP environment value or environment table
61 Set a handler function for incoming user file uploads.
65 @param callback Handler function
74 @param value Header value
78 Set the mime type of following content data.
82 @param mime Mimetype of following content
86 Get the RAW HTTP input source
90 @return HTTP LTN12 source
94 Set the HTTP status code and status message.
98 @param code Status code
99 @param message Status message
103 Send a chunk of content data to the client.
105 This function is as a valid LTN12 sink.
106 If the content chunk is nil this function will automatically invoke close.
110 @param content Content chunk
111 @param src_err Error object from source (optional)
116 Splice data from a filedescriptor to the client.
120 @param fp File descriptor
121 @param size Bytes to splice (optional)
125 Redirects the client to a new URL and closes the connection.
129 @param url Target URL
133 Create a querystring out of a table of key - value pairs.
136 @name build_querystring
137 @param table Query string source table
138 @return Encoded HTTP query string
142 Return the URL-decoded equivalent of a string.
146 @param str URL-encoded string
147 @param no_plus Don't decode + to " "
148 @return URL-decoded string
153 Return the URL-encoded equivalent of a string.
157 @param str Source string
158 @return URL-encoded string
163 Send the given data as JSON encoded string.
167 @param data Data to send
171 Extract and split urlencoded data pairs, separated bei either "&" or ";"
172 from given url or string. Returns a table with urldecoded values.
174 Simple parameters are stored as string values associated with the parameter
175 name within the table. Parameters with multiple values are stored as array
176 containing the corresponding values.
179 @name urldecode_params
180 @param url The url or string which contains x-www-urlencoded form data
181 @param tbl Use the given table for storing values (optional)
182 @return Table containing the urldecoded parameters
183 @see urlencode_params
187 Encode each key-value-pair in given table to x-www-urlencoded format,
190 Tables are encoded as parameters with multiple values by repeating the
191 parameter name with each value.
194 @name urlencode_params
195 @param tbl Table with the values
196 @return String containing encoded values
197 @see urldecode_params
201 Decode a mime encoded http message body with multipart/form-data Content-Type.
203 Stores all extracted data associated with its parameter name
204 in the params table within the given message object. Multiple parameter
205 values are stored as tables, ordinary ones as strings.
207 If an optional file callback function is given then it is feeded with the
208 file contents chunk by chunk and only the extracted file name is stored
209 within the params table. The callback function will be called subsequently
210 with three arguments:
211 o Table containing decoded (name, file) and raw (headers) mime header data
212 o String value containing a chunk of the file data
213 o Boolean which indicates wheather the current chunk is the last one (eof)
216 @name mimedecode_message_body
217 @param src Ltn12 source function
218 @param msg HTTP message object
219 @param filecb File callback function (optional)
220 @return Value indicating successful operation (not nil means "ok")
221 @return String containing the error if unsuccessful
222 @see parse_message_header
226 Decode an urlencoded http message body with application/x-www-urlencoded
229 Stores all extracted data associated with its parameter name in the params
230 table within the given message object. Multiple parameter values are stored
231 as tables, ordinary ones as strings.
234 @name urldecode_message_body
235 @param src Ltn12 source function
236 @param msg HTTP message object
237 @return Value indicating successful operation (not nil means "ok")
238 @return String containing the error if unsuccessful
239 @see parse_message_header
243 Try to extract and decode a http message body from the given ltn12 source.
244 This function will examine the Content-Type within the given message object
245 to select the appropriate content decoder.
247 Currently the application/x-www-urlencoded and application/form-data
248 mime types are supported. If the encountered content encoding can't be
249 handled then the whole message body will be stored unaltered as "content"
250 property within the given message object.
253 @name parse_message_body
254 @param src Ltn12 source function
255 @param msg HTTP message object
256 @param filecb File data callback (optional, see mimedecode_message_body())
257 @return Value indicating successful operation (not nil means "ok")
258 @return String containing the error if unsuccessful
259 @see parse_message_header