Pārlūkot izejas kodu

chunked_example: enforce to use chunked encoding

Previously MHD switches to identity encoding if connection
is not Keep-Alive
Evgeny Grin (Karlson2k) 4 gadi atpakaļ
vecāks
revīzija
81bbdc7048
1 mainītis faili ar 8 papildinājumiem un 0 dzēšanām
  1. 8 0
      src/examples/chunked_example.c

+ 8 - 0
src/examples/chunked_example.c

@@ -137,6 +137,14 @@ ahc_echo (void *cls,
     free (callback_param);
     free (callback_param);
     return MHD_NO;
     return MHD_NO;
   }
   }
+  /* Enforce chunked response, even for non-keep-alive connection. */
+  if (MHD_NO == MHD_add_response_header (response,
+                                         MHD_HTTP_HEADER_TRANSFER_ENCODING,
+                                         "chunked"))
+  {
+    free (callback_param);
+    return MHD_NO;
+  }
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   MHD_destroy_response (response);
   return ret;
   return ret;