From c27ec06b744f57189e4247410da09257b403ebbc Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 20 Sep 2018 20:08:34 +0200 Subject: fix root cause of #5337: curl interprets early response from MHD as error response (even though it is a 200 OK) and then aborted the upload; so we should wait with the response until the upload is complete --- src/test/test_twister_webserver.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/test/test_twister_webserver.c b/src/test/test_twister_webserver.c index bf32fcf..bb434c0 100644 --- a/src/test/test_twister_webserver.c +++ b/src/test/test_twister_webserver.c @@ -43,26 +43,33 @@ answer_to_connection const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) { - #if 0 +#if 0 const char *page = "Hello, browser!"; - #endif - +#endif const char *page = "{\"hello\": [{\"this\": \"browser!\"}],"\ "\"when\": \"today\"}"; - struct MHD_Response *response; int ret; + (void)cls; /* Unused. Silent compiler warning. */ (void)url; /* Unused. Silent compiler warning. */ (void)method; /* Unused. Silent compiler warning. */ (void)version; /* Unused. Silent compiler warning. */ (void)upload_data; /* Unused. Silent compiler warning. */ - (void)upload_data_size; /* Unused. Silent compiler warning. */ - (void)con_cls; /* Unused. Silent compiler warning. */ + if (NULL == (*con_cls)) + { + *con_cls = "first"; + return MHD_YES; + } + if (0 != *upload_data_size) + { + *upload_data_size = 0; + return MHD_YES; + } response = MHD_create_response_from_buffer (strlen (page), - (void *) page, + (void *) page, MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); -- cgit v1.2.3