diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-01-06 20:06:07 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-01-06 20:06:07 +0100 |
commit | ddb589b2632664e236175d94c5cd2178f992a532 (patch) | |
tree | 579b1151184519ac5d2c7f0556eb074753a9746c | |
parent | e86b06ba2cbf8779fa92b9b76c4229e15d173185 (diff) | |
download | nagios-plugin-curl-ddb589b2632664e236175d94c5cd2178f992a532.tar.gz nagios-plugin-curl-ddb589b2632664e236175d94c5cd2178f992a532.tar.bz2 |
made -ffollow work
-rw-r--r-- | src/check_curl.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/check_curl.c b/src/check_curl.c index bbb8d12..a9bf445 100644 --- a/src/check_curl.c +++ b/src/check_curl.c @@ -160,6 +160,13 @@ int main( int argc, char *argv[] ) { curl_easy_setopt( curl, CURLOPT_PORT, args_info.port_arg ); } + /* handle redirections */ + if( args_info.onredirect_given ) { + if( strcmp( args_info.onredirect_arg, "follow" ) == 0 ) { + curl_easy_setopt( curl, CURLOPT_FOLLOWLOCATION, 1 ); + } + } + /* compose HTTP headers */ if( args_info.host_given ) { snprintf( b2, (size_t)2048, "Host: %s", args_info.host_arg ); @@ -297,6 +304,11 @@ int main( int argc, char *argv[] ) { exit( STATE_CRITICAL ); } curl_easy_getinfo( curl, CURLINFO_RESPONSE_CODE, &code ); + if( args_info.onredirect_given ) { + if( strcmp( args_info.onredirect_arg, "follow" ) == 0 ) { + code = status_line.http_code; + } + } if( status_line.http_code != code ) { printf( "HTTP CRITICAL HTTP/%d.%d %d %s - different HTTP codes (cUrl has %ld) in %.3g seconds response time|%s\n", status_line.http_major, status_line.http_minor, |