twister

HTTP fault injector for testing
Log | Files | Refs | README | LICENSE

commit c27ec06b744f57189e4247410da09257b403ebbc
parent b4bbe2c09fe266bd74f3b76f00a7b88c3701bac1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 20 Sep 2018 20:08:34 +0200

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

Diffstat:
Msrc/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 @@ -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 = "<html><body>Hello, browser!</body></html>"; - #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);