diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-09-16 20:13:52 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-09-16 20:13:52 +0000 |
commit | 6ab7ebcb3194eadabf3c13106ec9a2d9a0c2c4dc (patch) | |
tree | 9a232e3323b865a4e222e984d1b1c973c53a283e /src | |
parent | 606c8196a0d1795f00eaba07ee6315b12aabfdd3 (diff) |
send_http_message() doesn't create a memory block and store it in the
connection's output_message variable. Instead the error is sent to the
client right away. Once we finish processing the client's headers it will
automatically accept the error message. So we get the same result, but
less memory is used.
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/utils.c b/src/utils.c index 8786702..9e3214c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,4 @@ -/* $Id: utils.c,v 1.12 2001-09-15 21:29:59 rjkaes Exp $ +/* $Id: utils.c,v 1.13 2001-09-16 20:13:52 rjkaes Exp $ * * Misc. routines which are used by the various functions to handle strings * and memory allocation and pretty much anything else we can think of. Also, @@ -84,7 +84,6 @@ int send_http_message(struct conn_s* connptr, int http_code, char *header_buffer; char timebuf[30]; time_t global_time; - int output_size; header_buffer = safemalloc(HEADER_SIZE); if (!header_buffer) @@ -95,18 +94,13 @@ int send_http_message(struct conn_s* connptr, int http_code, snprintf(header_buffer, HEADER_SIZE - 1, headers, http_code, error_title, PACKAGE, VERSION, timebuf, strlen(message)); - output_size = strlen(message) + strlen(header_buffer); - connptr->output_message = safemalloc(output_size + 1); - if (!connptr->output_message) { - safefree(header_buffer); - return -1; - } - - strlcpy(connptr->output_message, header_buffer, output_size); - strlcat(connptr->output_message, message, output_size); + safe_write(connptr->client_fd, header_buffer, strlen(header_buffer)); + safe_write(connptr->client_fd, message, strlen(message)); safefree(header_buffer); + connptr->send_message = TRUE; + return 0; } |