Jelajahi Sumber

fixing connection close issue mentioned by Robert Varga on MHD mailinglist

Christian Grothoff 14 tahun lalu
induk
melakukan
172aac8234
2 mengubah file dengan 11 tambahan dan 1 penghapusan
  1. 5 0
      ChangeLog
  2. 6 1
      src/daemon/connection.c

+ 5 - 0
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'

+ 6 - 1
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;