[multiple] dynamic handlers hint backend header sz

personal/stbuehler/fix-fdevent
Glenn Strauss 2018-11-12 00:33:06 -05:00
parent 31d16af78b
commit 9f6a46738d
3 changed files with 4 additions and 16 deletions

View File

@ -217,9 +217,7 @@ static handler_t fcgi_create_env(server *srv, handler_ctx *hctx) {
FCGI_Header header;
int request_id;
buffer *b = chunkqueue_prepend_buffer_open(hctx->wb);
gw_host *host = hctx->host;
connection *con = hctx->remote_conn;
http_cgi_opts opts = {
@ -229,6 +227,8 @@ static handler_t fcgi_create_env(server *srv, handler_ctx *hctx) {
host->strip_request_uri
};
buffer * const b = chunkqueue_prepend_buffer_open_sz(hctx->wb, (size_t)(con->read_queue->bytes_out - hctx->wb->bytes_in));
/* send FCGI_BEGIN_REQUEST */
if (hctx->request_id == 0) {
@ -245,10 +245,6 @@ static handler_t fcgi_create_env(server *srv, handler_ctx *hctx) {
beginRecord.body.flags = 0;
memset(beginRecord.body.reserved, 0, sizeof(beginRecord.body.reserved));
if ((off_t)buffer_string_space(b) < con->read_queue->bytes_out - hctx->wb->bytes_in) {
buffer_string_prepare_copy(b, ((size_t)(con->read_queue->bytes_out - hctx->wb->bytes_in + 4095) & ~4095uL)-1);
}
buffer_copy_string_len(b, (const char *)&beginRecord, sizeof(beginRecord));
fcgi_header(&header, FCGI_PARAMS, request_id, 0, 0); /*(set aside space to fill in later)*/
buffer_append_string_len(b, (const char *)&header, sizeof(header));

View File

@ -708,15 +708,11 @@ static void proxy_set_Forwarded(connection *con, const unsigned int flags) {
static handler_t proxy_create_env(server *srv, gw_handler_ctx *gwhctx) {
handler_ctx *hctx = (handler_ctx *)gwhctx;
connection *con = hctx->gw.remote_conn;
buffer *b = chunkqueue_prepend_buffer_open(hctx->gw.wb);
const int remap_headers = (NULL != hctx->conf.header.urlpaths
|| NULL != hctx->conf.header.hosts_request);
const int upgrade = hctx->conf.header.upgrade
&& (NULL != http_header_request_get(con, HTTP_HEADER_UPGRADE, CONST_STR_LEN("Upgrade")));
if ((off_t)buffer_string_space(b) < con->read_queue->bytes_out - hctx->gw.wb->bytes_in) {
buffer_string_prepare_copy(b, ((size_t)(con->read_queue->bytes_out - hctx->gw.wb->bytes_in + 4095) & ~4095uL)-1);
}
buffer * const b = chunkqueue_prepend_buffer_open_sz(hctx->gw.wb, (size_t)(con->read_queue->bytes_out - hctx->gw.wb->bytes_in));
/* build header */

View File

@ -156,7 +156,6 @@ static int scgi_env_add_uwsgi(void *venv, const char *key, size_t key_len, const
static handler_t scgi_create_env(server *srv, handler_ctx *hctx) {
buffer *b = chunkqueue_prepend_buffer_open(hctx->wb);
gw_host *host = hctx->host;
connection *con = hctx->remote_conn;
http_cgi_opts opts = { 0, 0, host->docroot, NULL };
@ -164,10 +163,7 @@ static handler_t scgi_create_env(server *srv, handler_ctx *hctx) {
? scgi_env_add_scgi
: scgi_env_add_uwsgi;
size_t offset;
if ((off_t)buffer_string_space(b) < con->read_queue->bytes_out - hctx->wb->bytes_in) {
buffer_string_prepare_copy(b, ((size_t)(con->read_queue->bytes_out - hctx->wb->bytes_in + 4095) & ~4095uL)-1);
}
buffer * const b = chunkqueue_prepend_buffer_open_sz(hctx->wb, (size_t)(con->read_queue->bytes_out - hctx->wb->bytes_in));
/* save space for 9 digits (plus ':'), though incoming HTTP request
* currently limited to 64k (65535, so 5 chars) */