summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-05-06 17:39:59 (GMT)
committerSven Nierlein <sven@nierlein.de>2018-10-22 14:30:31 (GMT)
commit00cb1408adf1725ee05c1fe928c9207b7acc235b (patch)
tree45e8777b36517a637f74b281afd8ac91740652f8 /plugins/check_curl.c
parenta739a5614834178ba88d04972b4f4ba9c560e1df (diff)
downloadmonitoring-plugins-00cb1408adf1725ee05c1fe928c9207b7acc235b.tar.gz
fixed redirect sticky port handling in redir
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 72db27a..3ae1c4d 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -551,7 +551,7 @@ check_http (void)
551 CURLINFO_REDIRECT_COUNT: get the number of redirects, print it, maybe a range option here is nice like for expected page size? 551 CURLINFO_REDIRECT_COUNT: get the number of redirects, print it, maybe a range option here is nice like for expected page size?
552 */ 552 */
553 } else { 553 } else {
554 // old style redirection is handled below 554 /* old style redirection is handled below */
555 } 555 }
556 } 556 }
557 557
@@ -1019,6 +1019,8 @@ redir (curlhelp_write_curlbuf* header_buf)
1019 new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE)); 1019 new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE));
1020 } 1020 }
1021 1021
1022 /* compose new path */
1023 /* TODO: handle fragments and query part of URL */
1022 new_url = (char *)calloc( 1, DEFAULT_BUFFER_SIZE); 1024 new_url = (char *)calloc( 1, DEFAULT_BUFFER_SIZE);
1023 if (uri.pathHead) { 1025 if (uri.pathHead) {
1024 const UriPathSegmentA* p = uri.pathHead; 1026 const UriPathSegmentA* p = uri.pathHead;
@@ -1038,23 +1040,21 @@ redir (curlhelp_write_curlbuf* header_buf)
1038 1040
1039 /* set new values for redirected request */ 1041 /* set new values for redirected request */
1040 1042
1041 free (host_name);
1042 host_name = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1043 free(new_host);
1044
1045 server_port = (unsigned short)new_port;
1046
1047 /* reset virtual port */
1048 virtual_port = server_port;
1049
1050 if (!(followsticky & STICKY_HOST)) { 1043 if (!(followsticky & STICKY_HOST)) {
1051 free (server_address); 1044 free (server_address);
1052 server_address = strndup (new_host, MAX_IPV4_HOSTLENGTH); 1045 server_address = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1053 } 1046 }
1054 if (!(followsticky & STICKY_PORT)) { 1047 if (!(followsticky & STICKY_PORT)) {
1055 server_port = new_port; 1048 server_port = (unsigned short)new_port;
1056 } 1049 }
1057 1050
1051 free (host_name);
1052 host_name = strndup (new_host, MAX_IPV4_HOSTLENGTH);
1053
1054 /* reset virtual port */
1055 virtual_port = server_port;
1056
1057 free(new_host);
1058 free (server_url); 1058 free (server_url);
1059 server_url = new_url; 1059 server_url = new_url;
1060 1060