diff --git a/src/utils.c b/src/utils.c index 4496f75..a4516b2 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,4 @@ -/* $Id: utils.c,v 1.20 2001-12-20 04:48:52 rjkaes Exp $ +/* $Id: utils.c,v 1.21 2001-12-24 00:02:32 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, @@ -77,33 +77,29 @@ int send_http_message(struct conn_s *connptr, int http_code, const char *error_title, const char *message) { - static char *headers = - "HTTP/1.0 %d %s\r\n" - "Server: %s/%s\r\n" - "Date: %s\r\n" - "Content-Type: text/html\r\n" - "Content-Length: %d\r\n" "Connection: close\r\n" "\r\n"; + static char *headers = \ + "HTTP/1.0 %d %s\r\n" \ + "Server: %s/%s\r\n" \ + "Date: %s\r\n" \ + "Content-Type: text/html\r\n" \ + "Content-Length: %d\r\n" \ + "Connection: close\r\n" \ + "\r\n"; - char *header_buffer; char timebuf[30]; time_t global_time; - header_buffer = safemalloc(HEADER_SIZE); - if (!header_buffer) - return -1; - global_time = time(NULL); strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&global_time)); - snprintf(header_buffer, HEADER_SIZE - 1, headers, http_code, - error_title, PACKAGE, VERSION, timebuf, strlen(message)); + write_message(connptr->client_fd, + headers, + http_code, error_title, PACKAGE, VERSION, timebuf, + strlen(message)); - safe_write(connptr->client_fd, header_buffer, strlen(header_buffer)); safe_write(connptr->client_fd, message, strlen(message)); - safefree(header_buffer); - connptr->send_response_message = TRUE; return 0; @@ -115,31 +111,50 @@ send_http_message(struct conn_s *connptr, int http_code, int httperr(struct conn_s *connptr, int err, const char *msg) { - static char *message = - "