commit 172aac82344205fafec5cb9e01bef5400d5be078
parent a88ac9f2ec3ed569746309fdab1766a178fee829
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 22 Jun 2011 12:33:32 +0000
fixing connection close issue mentioned by Robert Varga on MHD mailinglist
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jun 22 14:32:23 CEST 2011
+ Force closing connection if either the client asked it or
+ if the response contains 'Connection: close' (so far,
+ only the client's request was considered). -CG/RV
+
Wed Jun 22 10:37:35 CEST 2011
Removing listen socket from poll/select sets in
MHD_USE_THREAD_PER_CONNECTION mode; using 'shutdown'
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
@@ -1935,6 +1935,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
struct MHD_Daemon *daemon;
unsigned int timeout;
const char *end;
+ int rend;
char *line;
while (1)
@@ -2205,6 +2206,10 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
sizeof (val));
}
#endif
+ end =
+ MHD_get_response_header (connection->response,
+ MHD_HTTP_HEADER_CONNECTION);
+ rend = ( (end != NULL) && (0 == strcasecmp (end, "close")) );
MHD_destroy_response (connection->response);
connection->response = NULL;
if (connection->daemon->notify_completed != NULL)
@@ -2229,7 +2234,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
connection->write_buffer_size = 0;
connection->write_buffer_send_offset = 0;
connection->write_buffer_append_offset = 0;
- if ((end != NULL) && (0 == strcasecmp (end, "close")))
+ if ( (rend) || ((end != NULL) && (0 == strcasecmp (end, "close"))) )
{
connection->read_closed = MHD_YES;
connection->read_buffer_offset = 0;