summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/check_curl.c12
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,