diff --git a/src/connections.c b/src/connections.c index a6af3402..c188a8d6 100644 --- a/src/connections.c +++ b/src/connections.c @@ -310,12 +310,11 @@ static int connection_handle_write_prepare(server *srv, connection *con) { } if (!con->file_finished) { - buffer *b; + buffer *b = srv->tmp_buf; buffer_reset(con->physical.path); con->file_finished = 1; - b = buffer_init(); /* build default error-page */ buffer_copy_string_len(b, CONST_STR_LEN( @@ -339,8 +338,7 @@ static int connection_handle_write_prepare(server *srv, connection *con) { "\n" )); - (void)http_chunk_append_buffer(srv, con, b); - buffer_free(b); + (void)http_chunk_append_mem(srv, con, CONST_BUF_LEN(b)); http_header_response_set(con, HTTP_HEADER_CONTENT_TYPE, CONST_STR_LEN("Content-Type"), CONST_STR_LEN("text/html")); } diff --git a/src/http-header-glue.c b/src/http-header-glue.c index fda60330..f6e2e3b7 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -325,8 +325,7 @@ static int http_response_parse_range(server *srv, connection *con, buffer *path, if (!error) { if (multipart) { /* write boundary-header */ - buffer *b = buffer_init(); - + buffer *b = srv->tmp_buf; buffer_copy_string_len(b, CONST_STR_LEN("\r\n--")); buffer_append_string_len(b, boundary, sizeof(boundary)-1); @@ -347,8 +346,7 @@ static int http_response_parse_range(server *srv, connection *con, buffer *path, buffer_append_string_len(b, CONST_STR_LEN("\r\n\r\n")); con->response.content_length += buffer_string_length(b); - chunkqueue_append_buffer(con->write_queue, b); - buffer_free(b); + chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b)); } chunkqueue_append_file(con->write_queue, path, start, end - start + 1); @@ -361,15 +359,13 @@ static int http_response_parse_range(server *srv, connection *con, buffer *path, if (multipart) { /* add boundary end */ - buffer *b = buffer_init(); - + buffer *b = srv->tmp_buf; buffer_copy_string_len(b, "\r\n--", 4); buffer_append_string_len(b, boundary, sizeof(boundary)-1); buffer_append_string_len(b, "--\r\n", 4); con->response.content_length += buffer_string_length(b); - chunkqueue_append_buffer(con->write_queue, b); - buffer_free(b); + chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b)); /* set header-fields */ diff --git a/src/http_chunk.c b/src/http_chunk.c index 92c65e83..317b9b4e 100644 --- a/src/http_chunk.c +++ b/src/http_chunk.c @@ -33,7 +33,7 @@ static void http_chunk_append_len(server *srv, connection *con, uintmax_t len) { buffer_append_uint_hex(b, len); buffer_append_string_len(b, CONST_STR_LEN("\r\n")); - chunkqueue_append_buffer(con->write_queue, b); + chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b)); } static int http_chunk_append_file_open_fstat(server *srv, connection *con, buffer *fn, struct stat *st) { diff --git a/src/mod_ssi.c b/src/mod_ssi.c index 286a47d6..0259fabc 100644 --- a/src/mod_ssi.c +++ b/src/mod_ssi.c @@ -371,7 +371,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const case SSI_ECHO_USER_NAME: { struct passwd *pw; - b = buffer_init(); + b = srv->tmp_buf; #ifdef HAVE_PWD_H if (NULL == (pw = getpwuid(st->st_uid))) { buffer_copy_int(b, st->st_uid); @@ -381,8 +381,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const #else buffer_copy_int(b, st->st_uid); #endif - chunkqueue_append_buffer(con->write_queue, b); - buffer_free(b); + chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b)); break; } case SSI_ECHO_LAST_MODIFIED: { @@ -580,7 +579,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const switch (ssicmd) { case SSI_FSIZE: - b = buffer_init(); + b = srv->tmp_buf; if (p->sizefmt) { int j = 0; const char *abr[] = { " B", " kB", " MB", " GB", " TB", NULL }; @@ -594,8 +593,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const } else { buffer_copy_int(b, stb.st_size); } - chunkqueue_append_buffer(con->write_queue, b); - buffer_free(b); + chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b)); break; case SSI_FLASTMOD: if (0 == strftime(buf, sizeof(buf), p->timefmt->ptr, localtime(&t))) { @@ -719,7 +717,8 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const case SSI_PRINTENV: if (p->if_is_false) break; - b = buffer_init(); + b = srv->tmp_buf; + buffer_string_set_length(b, 0); for (i = 0; i < p->ssi_vars->used; i++) { data_string *ds = (data_string *)p->ssi_vars->data[p->ssi_vars->sorted[i]]; @@ -736,9 +735,7 @@ static int process_ssi_stmt(server *srv, connection *con, handler_ctx *p, const buffer_append_string_encoded(b, CONST_BUF_LEN(ds->value), ENCODING_MINIMAL_XML); buffer_append_string_len(b, CONST_STR_LEN("\n")); } - chunkqueue_append_buffer(con->write_queue, b); - buffer_free(b); - + chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b)); break; case SSI_EXEC: { const char *cmd = NULL; diff --git a/src/mod_uploadprogress.c b/src/mod_uploadprogress.c index d8a0c0ad..9a1375a5 100644 --- a/src/mod_uploadprogress.c +++ b/src/mod_uploadprogress.c @@ -356,9 +356,8 @@ URIHANDLER_FUNC(mod_uploadprogress_uri_handler) { http_header_response_set(con, HTTP_HEADER_OTHER, CONST_STR_LEN("Expires"), CONST_STR_LEN("Thu, 19 Nov 1981 08:52:00 GMT")); http_header_response_set(con, HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control"), CONST_STR_LEN("no-store, no-cache, must-revalidate, post-check=0, pre-check=0")); - b = buffer_init(); - /* prepare XML */ + b = srv->tmp_buf; buffer_copy_string_len(b, CONST_STR_LEN( "" "" @@ -371,14 +370,7 @@ URIHANDLER_FUNC(mod_uploadprogress_uri_handler) { buffer_append_string_len(b, CONST_STR_LEN( "" "")); - -#if 0 - log_error_write(srv, __FILE__, __LINE__, "sb", "...", b); -#endif - - chunkqueue_append_buffer(con->write_queue, b); - buffer_free(b); - + chunkqueue_append_mem(con->write_queue, CONST_BUF_LEN(b)); return HANDLER_FINISHED; default: break;