twister

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

commit e01669953d7a8e82a505fca2308e57e971d43c67
parent 70d25f10e9ba93a26784949fdcf4e718d8c1ba52
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Wed, 30 May 2018 20:48:26 +0200

Make sure that upload cb is registered with assert.

Diffstat:
Msrc/test/test_twister_webserver.c | 30+++++++++++++++---------------
Msrc/twister/taler-twister-service.c | 35+++++++++++++++++++++++------------
2 files changed, 38 insertions(+), 27 deletions(-)

diff --git a/src/test/test_twister_webserver.c b/src/test/test_twister_webserver.c @@ -1,22 +1,22 @@ /* - This file is part of Taler. - Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V. - Copyright (C) 2018 Taler Systems SA + This file is part of Taler. + Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V. + Copyright (C) 2018 Taler Systems SA - Taler is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 3, - or (at your option) any later version. + Taler is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 3, + or (at your option) any later version. - Taler is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + Taler is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public - License along with Taler; see the file COPYING. If not, - write to the Free Software Foundation, Inc., 51 Franklin - Street, Fifth Floor, Boston, MA 02110-1301, USA. + You should have received a copy of the GNU General Public + License along with Taler; see the file COPYING. If not, + write to the Free Software Foundation, Inc., 51 Franklin + Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c @@ -499,8 +499,7 @@ curl_upload_cb (void *buf, size_t to_copy; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Uploader cb, size: %u.\n", - (unsigned int) size); + "Upload cb is working...\n"); if (REQUEST_STATE_UPLOAD_STARTED != hr->state) { @@ -1155,7 +1154,7 @@ create_response (void *cls, return MHD_YES; } - /* Upload (from the *client*) finished, + /* Upload (*from the client*) finished, * generate curl request to the proxied service. */ if (NULL == hr->curl) { @@ -1294,9 +1293,11 @@ create_response (void *cls, const char *us; long upload_size; - us = MHD_lookup_connection_value (con, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_CONTENT_LENGTH); + us = MHD_lookup_connection_value + (con, + MHD_HEADER_KIND, + MHD_HTTP_HEADER_CONTENT_LENGTH); + if ( (1 == sscanf (us, "%ld", &upload_size)) && @@ -1315,13 +1316,20 @@ create_response (void *cls, else if (0 == strcasecmp (meth, MHD_HTTP_METHOD_POST)) { + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Crafting a CURL POST request\n"); + hr->state = REQUEST_STATE_UPLOAD_STARTED; curl_easy_setopt (hr->curl, CURLOPT_POST, 1L); - curl_easy_setopt (hr->curl, - CURLOPT_READFUNCTION, - &curl_upload_cb); + GNUNET_assert + (CURLE_OK == curl_easy_setopt + (hr->curl, + CURLOPT_READFUNCTION, + &curl_upload_cb)); + curl_easy_setopt (hr->curl, CURLOPT_READDATA, hr); @@ -1329,9 +1337,11 @@ create_response (void *cls, const char *us; long upload_size; - us = MHD_lookup_connection_value (con, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_CONTENT_LENGTH); + us = MHD_lookup_connection_value + (con, + MHD_HEADER_KIND, + MHD_HTTP_HEADER_CONTENT_LENGTH); + if ( (1 == sscanf (us, "%ld", &upload_size)) && @@ -1342,6 +1352,7 @@ create_response (void *cls, upload_size); } } + curl_easy_setopt (hr->curl, CURLOPT_WRITEFUNCTION, &curl_download_cb);