diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2019-06-07 19:24:01 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2019-06-07 19:24:01 +0200 |
commit | d690ce32b5d0a2044840bcacc9619b1c0ce858c2 (patch) | |
tree | c6c7b2214d6577f7dccc6073a8eeb6d15671f95a | |
parent | 6765b1339e6f98e64a56e59e7c20aa6abb59ce20 (diff) | |
download | twister-d690ce32b5d0a2044840bcacc9619b1c0ce858c2.tar.gz twister-d690ce32b5d0a2044840bcacc9619b1c0ce858c2.tar.bz2 twister-d690ce32b5d0a2044840bcacc9619b1c0ce858c2.zip |
keep the ":<portnumber>" in the host header.
-rwxr-xr-x | src/test/test_twister.sh | 2 | ||||
-rw-r--r-- | src/twister/taler-twister-service.c | 41 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/test/test_twister.sh b/src/test/test_twister.sh index 52a38a6..0347f66 100755 --- 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 index d147d96..30dee63 100644 --- 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, |