From ddb589b2632664e236175d94c5cd2178f992a532 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 6 Jan 2017 20:06:07 +0100 Subject: made -ffollow work --- src/check_curl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') 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, -- cgit v1.2.3-54-g00ecf