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

Function lua_read_body

modules/lua/lua_request.c:233–271  ·  view source on GitHub ↗

======================================================================================================================= lua_read_body(request_rec *r, const char **rbuf, apr_off_t *size): Reads any additional form data sent in POST/PUT requests. Used for multipart POST data. ====================================================================================================================

Source from the content-addressed store, hash-verified

231 =======================================================================================================================
232 */
233static int lua_read_body(request_rec *r, const char **rbuf, apr_off_t *size,
234 apr_off_t maxsize)
235{
236 int rc = OK;
237
238 *rbuf = NULL;
239 *size = 0;
240
241 if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
242 return (rc);
243 }
244 if (ap_should_client_block(r)) {
245
246 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
247 apr_off_t len_read = -1;
248 apr_off_t rpos = 0;
249 apr_off_t length = r->remaining;
250 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
251
252 if (maxsize != 0 && length > maxsize) {
253 return APR_EINCOMPLETE; /* Only room for incomplete data chunk :( */
254 }
255 *rbuf = (const char *) apr_pcalloc(r->pool, (apr_size_t) (length) + 1);
256 while ((rpos < length)
257 && (len_read = ap_get_client_block(r, (char *) *rbuf + rpos,
258 length - rpos)) > 0) {
259 rpos += len_read;
260 }
261 if (len_read < 0) {
262 return APR_EINCOMPLETE;
263 }
264 *size = rpos;
265 }
266 else {
267 rc = DONE;
268 }
269
270 return (rc);
271}
272
273
274/*

Callers 2

req_parsebodyFunction · 0.85
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