diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-06 19:39:59 +0200 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2018-10-22 16:30:31 +0200 |
commit | 00cb1408adf1725ee05c1fe928c9207b7acc235b (patch) | |
tree | 45e8777b36517a637f74b281afd8ac91740652f8 /plugins | |
parent | a739a5614834178ba88d04972b4f4ba9c560e1df (diff) | |
download | monitoring-plugins-00cb1408adf1725ee05c1fe928c9207b7acc235b.tar.gz |
fixed redirect sticky port handling in redir
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_curl.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 72db27ad..3ae1c4d0 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c @@ -551,7 +551,7 @@ check_http (void) CURLINFO_REDIRECT_COUNT: get the number of redirects, print it, maybe a range option here is nice like for expected page size? */ } else { - // old style redirection is handled below + /* old style redirection is handled below */ } } @@ -1019,6 +1019,8 @@ redir (curlhelp_write_curlbuf* header_buf) new_host = strdup (uri_string (uri.hostText, buf, DEFAULT_BUFFER_SIZE)); } + /* compose new path */ + /* TODO: handle fragments and query part of URL */ new_url = (char *)calloc( 1, DEFAULT_BUFFER_SIZE); if (uri.pathHead) { const UriPathSegmentA* p = uri.pathHead; @@ -1038,23 +1040,21 @@ redir (curlhelp_write_curlbuf* header_buf) /* set new values for redirected request */ - free (host_name); - host_name = strndup (new_host, MAX_IPV4_HOSTLENGTH); - free(new_host); - - server_port = (unsigned short)new_port; - - /* reset virtual port */ - virtual_port = server_port; - if (!(followsticky & STICKY_HOST)) { free (server_address); server_address = strndup (new_host, MAX_IPV4_HOSTLENGTH); } if (!(followsticky & STICKY_PORT)) { - server_port = new_port; + server_port = (unsigned short)new_port; } + free (host_name); + host_name = strndup (new_host, MAX_IPV4_HOSTLENGTH); + + /* reset virtual port */ + virtual_port = server_port; + + free(new_host); free (server_url); server_url = new_url; |