MCPcopy Create free account
hub / github.com/apache/httpd / lua_write_body

Function lua_write_body

modules/lua/lua_request.c:280–316  ·  view source on GitHub ↗

* ======================================================================================================================= * lua_write_body: Reads any additional form data sent in POST/PUT requests * and writes to a file. * ======================================================================================================================= */

Source from the content-addressed store, hash-verified

278 * =======================================================================================================================
279 */
280static apr_status_t lua_write_body(request_rec *r, apr_file_t *file, apr_off_t *size)
281{
282 apr_status_t rc = OK;
283
284 *size = 0;
285
286 if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
287 return rc;
288 if (ap_should_client_block(r)) {
289 char argsbuffer[HUGE_STRING_LEN];
290 apr_off_t rsize,
291 len_read,
292 rpos = 0;
293 apr_off_t length = r->remaining;
294
295 *size = length;
296 while ((len_read =
297 ap_get_client_block(r, argsbuffer,
298 sizeof(argsbuffer))) > 0) {
299 if ((rpos + len_read) > length)
300 rsize = (apr_size_t) length - rpos;
301 else
302 rsize = len_read;
303
304 rc = apr_file_write_full(file, argsbuffer, (apr_size_t) rsize,
305 NULL);
306 if (rc != APR_SUCCESS)
307 return rc;
308 rpos += rsize;
309 }
310 }
311 else {
312 rc = DONE;
313 }
314
315 return rc;
316}
317
318/* expose apr_table as (r/o) lua table */
319static int req_aprtable2luatable(lua_State *L, apr_table_t *t)

Callers 1

lua_ap_requestbodyFunction · 0.85

Calls 3

ap_setup_client_blockFunction · 0.85
ap_should_client_blockFunction · 0.85
ap_get_client_blockFunction · 0.85

Tested by

no test coverage detected