twister

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

commit d690ce32b5d0a2044840bcacc9619b1c0ce858c2
parent 6765b1339e6f98e64a56e59e7c20aa6abb59ce20
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Fri,  7 Jun 2019 19:24:01 +0200

keep the ":<portnumber>" in the host header.

Diffstat:
Msrc/test/test_twister.sh | 2+-
Msrc/twister/taler-twister-service.c | 41+++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/src/test/test_twister.sh b/src/test/test_twister.sh @@ -48,7 +48,7 @@ twister_service_pid=$! echo Twister launched. sleep 1 -if ! ps xo pid | grep ${twister_service_pid}; then +if ! ps xo pid | grep -q ${twister_service_pid}; then echo Twister did not start correctly return 77 fi diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c @@ -662,6 +662,40 @@ curl_upload_cb (void *buf, } +/* ************** helper functions ************* */ + +/** + * Extract the hostname from a complete URL. + * + * @param url full fledged URL + * + * @return pointer to the 0-terminated hostname, to be freed + * by the caller. + */ +static char * +build_host_header (const char *url) +{ + #define MARKER "://" + + char *header; + char *end; + char *hostname; + char *dup = GNUNET_strdup (url); + + hostname = strstr (dup, MARKER); + hostname+=3; + + end = strchrnul (hostname, '/'); + *end = '\0'; + + GNUNET_asprintf (&header, + "Host: %s", + hostname); + + GNUNET_free (dup); + return header; +} + /* ************** main loop of cURL interaction ************* */ @@ -1607,6 +1641,7 @@ create_response (void *cls, hr); { char *curlurl; + char *host_hdr; GNUNET_asprintf (&curlurl, "%s%s", @@ -1619,6 +1654,12 @@ create_response (void *cls, "Forwarding request to: %s\n", curlurl); GNUNET_free (curlurl); + + host_hdr = build_host_header (target_server_base_url); + + curl_slist_append (hr->headers, + host_hdr); + GNUNET_free (host_hdr); } if (0 == strcasecmp (meth,