From f7d08df1b88e1b3610aeae2ec30627982523fee5 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 9 Nov 2012 10:47:42 +0000 Subject: [PATCH] Let finish_http_response() advertise that the Content-Length header has been set This allows jcc.c v1.412's serve() to keep the client connection open. --- cgi.c | 9 +++++++-- cgi.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cgi.c b/cgi.c index 9e1e8e41..950d885b 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.155 2012/09/18 18:29:55 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.156 2012/10/21 12:54:15 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -1570,7 +1570,7 @@ char *compress_buffer(char *buffer, size_t *buffer_length, int compression_level * On error, free()s rsp and returns cgi_error_memory() * *********************************************************************/ -struct http_response *finish_http_response(const struct client_state *csp, struct http_response *rsp) +struct http_response *finish_http_response(struct client_state *csp, struct http_response *rsp) { char buf[BUFFER_SIZE]; jb_err err; @@ -1620,6 +1620,11 @@ struct http_response *finish_http_response(const struct client_state *csp, struc if (!err) { snprintf(buf, sizeof(buf), "Content-Length: %d", (int)rsp->content_length); + /* + * Signal serve() that the client will be able to figure out + * the end of the response without having to close the connection. + */ + csp->flags |= CSP_FLAG_SERVER_CONTENT_LENGTH_SET; err = enlist(rsp->headers, buf); } diff --git a/cgi.h b/cgi.h index a7deedee..09e03472 100644 --- a/cgi.h +++ b/cgi.h @@ -1,6 +1,6 @@ #ifndef CGI_H_INCLUDED #define CGI_H_INCLUDED -#define CGI_H_VERSION "$Id: cgi.h,v 1.40 2011/07/08 13:27:31 fabiankeil Exp $" +#define CGI_H_VERSION "$Id: cgi.h,v 1.41 2011/09/04 11:10:56 fabiankeil Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.h,v $ @@ -60,7 +60,7 @@ extern struct http_response *error_response(struct client_state *csp, extern struct http_response * alloc_http_response(void); extern void free_http_response(struct http_response *rsp); -extern struct http_response *finish_http_response(const struct client_state *csp, +extern struct http_response *finish_http_response(struct client_state *csp, struct http_response *rsp); extern struct map * default_exports(const struct client_state *csp, const char *caller); -- 2.39.2