[core] add option to disable buffering large request bodies on disk - forward them to backend directly instead
- right now only mod_fastcgi can handle this (it won't set the CONTENT_LENGTH env var, the backend has to support this too)personal/stbuehler/wip
parent
38aad8128e
commit
97dbcf7e42
|
@ -15,7 +15,9 @@ enum liCoreOptions {
|
|||
|
||||
LI_CORE_OPTION_ETAG_FLAGS,
|
||||
|
||||
LI_CORE_OPTION_ASYNC_STAT
|
||||
LI_CORE_OPTION_ASYNC_STAT,
|
||||
|
||||
LI_CORE_OPTION_BUFFER_ON_DISK_REQUEST_BODY
|
||||
};
|
||||
|
||||
enum liCoreOptionPtrs {
|
||||
|
|
|
@ -352,6 +352,7 @@ static void _connection_http_in_cb(liStream *stream, liStreamEvent event) {
|
|||
li_connection_error(con);
|
||||
return;
|
||||
}
|
||||
if (in->is_closed) vr->request.content_length = in->bytes_in;
|
||||
newbytes = 1; /* always notify */
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1892,6 +1892,8 @@ static const liPluginOption options[] = {
|
|||
|
||||
{ "stat.async", LI_VALUE_BOOLEAN, TRUE, NULL },
|
||||
|
||||
{ "buffer_request_body", LI_VALUE_BOOLEAN, TRUE, NULL },
|
||||
|
||||
{ NULL, 0, 0, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -308,6 +308,9 @@ gboolean li_vrequest_wait_for_request_body(liVRequest *vr) {
|
|||
return FALSE; /* still waiting */
|
||||
}
|
||||
|
||||
/* don't start waiting if buffer isn't enabled */
|
||||
if (!CORE_OPTION(LI_CORE_OPTION_BUFFER_ON_DISK_REQUEST_BODY).boolean) return TRUE;
|
||||
|
||||
lim_avail = li_chunkqueue_limit_available(vr->coninfo->req->out);
|
||||
|
||||
vr->wait_for_request_body_stream = wait_for_request_body_stream_new(vr);
|
||||
|
|
|
@ -90,8 +90,15 @@ static void proxy_send_headers(liVRequest *vr, liChunkQueue *out) {
|
|||
}
|
||||
}
|
||||
|
||||
if (vr->request.content_length > 0) {
|
||||
g_string_append_printf(head, "Content-Length: %" LI_GOFFSET_MODIFIER "i\r\n", vr->request.content_length);
|
||||
}
|
||||
|
||||
for (iter = g_queue_peek_head_link(&vr->request.headers->entries); iter; iter = g_list_next(iter)) {
|
||||
header = (liHttpHeader*) iter->data;
|
||||
if (li_http_header_key_is(header, CONST_STR_LEN("Content-Length"))) continue;
|
||||
if (li_http_header_key_is(header, CONST_STR_LEN("Transfer-Encoding"))) continue;
|
||||
if (li_http_header_key_is(header, CONST_STR_LEN("TE"))) continue;
|
||||
if (li_http_header_key_is(header, CONST_STR_LEN("Connection"))) continue;
|
||||
if (li_http_header_key_is(header, CONST_STR_LEN("Proxy-Connection"))) continue;
|
||||
if (li_http_header_key_is(header, CONST_STR_LEN("X-Forwarded-Proto"))) continue;
|
||||
|
@ -260,6 +267,11 @@ static liHandlerResult proxy_handle(liVRequest *vr, gpointer param, gpointer *co
|
|||
|
||||
LI_VREQUEST_WAIT_FOR_REQUEST_BODY(vr);
|
||||
|
||||
if (vr->request.content_length < 0) {
|
||||
VR_ERROR(vr, "%s", "proxy can't handle progressive uploads yet. enable request body buffering!");
|
||||
return LI_HANDLER_ERROR;
|
||||
}
|
||||
|
||||
switch (li_backend_get(vr, ctx->pool, &bcon, &bwait)) {
|
||||
case LI_BACKEND_SUCCESS:
|
||||
assert(NULL == bwait);
|
||||
|
|
|
@ -353,6 +353,11 @@ static liHandlerResult scgi_handle(liVRequest *vr, gpointer param, gpointer *con
|
|||
|
||||
LI_VREQUEST_WAIT_FOR_REQUEST_BODY(vr);
|
||||
|
||||
if (vr->request.content_length < 0) {
|
||||
VR_ERROR(vr, "%s", "scgi can't handle progressive uploads. enable request body buffering!");
|
||||
return LI_HANDLER_ERROR;
|
||||
}
|
||||
|
||||
switch (li_backend_get(vr, ctx->pool, &bcon, &bwait)) {
|
||||
case LI_BACKEND_SUCCESS:
|
||||
assert(NULL == bwait);
|
||||
|
|
Loading…
Reference in New Issue