--- frontends/php/include/httptest.inc.php.orig	2009-06-16 08:12:36.000000000 -0500
+++ frontends/php/include/httptest.inc.php	2009-07-30 19:56:41.826163828 -0500
@@ -45,7 +45,7 @@
 		return $status;
 	}
 
-	function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $posts, $required, $status_codes, $delay, $history, $trends){
+	function db_save_step($hostid, $applicationid, $httptestid, $testname, $name, $no, $timeout, $url, $redirect, $posts, $required, $status_codes, $delay, $history, $trends){
 		if($no <= 0){
 			error('Scenario step number can\'t be less then 1');
 			return false;
@@ -61,9 +61,9 @@
 			$httpstepid = get_dbid("httpstep","httpstepid");
 			
 			if (!DBexecute('insert into httpstep'.
-				' (httpstepid, httptestid, name, no, url, timeout, posts, required, status_codes) '.
+				' (httpstepid, httptestid, name, no, url, redirect, timeout, posts, required, status_codes) '.
 				' values ('.$httpstepid.','.$httptestid.','.zbx_dbstr($name).','.$no.','.
-				zbx_dbstr($url).','.$timeout.','.
+				zbx_dbstr($url).','.$redirect.','.$timeout.','.
 				zbx_dbstr($posts).','.zbx_dbstr($required).','.zbx_dbstr($status_codes).')'
 				)) return false;
 		}
@@ -71,7 +71,7 @@
 			$httpstepid = $httpstep_data['httpstepid'];
 
 			if (!DBexecute('update httpstep set '.
-				' name='.zbx_dbstr($name).', no='.$no.', url='.zbx_dbstr($url).', timeout='.$timeout.','.
+				' name='.zbx_dbstr($name).', no='.$no.', url='.zbx_dbstr($url).', redirect='.$redirect.', timeout='.$timeout.','.
 				' posts='.zbx_dbstr($posts).', required='.zbx_dbstr($required).', status_codes='.zbx_dbstr($status_codes).
 				' where httpstepid='.$httpstepid)) return false;
 		}
@@ -228,12 +228,13 @@
 				if(!isset($s['name']))		$s['name'] = '';
 				if(!isset($s['timeout']))	$s['timeout'] = 15;
 				if(!isset($s['url']))       	$s['url'] = '';
+				if(!isset($s['redirect']))	$s['redirect'] = 1;
 				if(!isset($s['posts']))       	$s['posts'] = '';
 				if(!isset($s['required']))      $s['required'] = '';
 				if(!isset($s['status_codes']))  $s['status_codes'] = '';
 			
 				$result = db_save_step($hostid, $applicationid, $httptestid,
-						$name, $s['name'], $sid+1, $s['timeout'], $s['url'], $s['posts'], $s['required'],$s['status_codes'],
+						$name, $s['name'], $sid+1, $s['timeout'], $s['url'], $s['redirect'], $s['posts'], $s['required'],$s['status_codes'],
 						$delay, $history, $trends);
 				
 				if(!$result) break;
--- frontends/php/include/forms.inc.php.orig	2009-06-16 08:12:36.000000000 -0500
+++ frontends/php/include/forms.inc.php	2009-07-30 19:56:41.825167332 -0500
@@ -309,6 +309,7 @@
 		$stepid = get_request('stepid', null);
 		$name = get_request('name', '');
 		$url = get_request('url', '');
+		$redirect = get_request('redirect', 1);
 		$posts = get_request('posts', '');
 		$timeout = get_request('timeout', 15);
 		$required = get_request('required', '');
@@ -316,6 +317,7 @@
 
 		$form->AddRow(S_NAME, new CTextBox('name', $name, 50));
 		$form->AddRow(S_URL, new CTextBox('url', $url, 80));
+		$form->AddRow(S_REDIRECT, new CCheckBox('redirect',$redirect));
 		$form->AddRow(S_POST, new CTextArea('posts', $posts, 50, 10));
 		$form->AddRow(S_TIMEOUT, new CNumericBox('timeout', $timeout, 5));
 		$form->AddRow(S_REQUIRED, new CTextBox('required', $required, 80));
@@ -417,6 +419,7 @@
 			if(!isset($s['name']))		$s['name'] = '';
 			if(!isset($s['timeout']))	$s['timeout'] = 15;
 			if(!isset($s['url']))       	$s['url'] = '';
+			if(!isset($s['redirect']))      $s['redirect'] = 1;
 			if(!isset($s['posts']))       	$s['posts'] = '';
 			if(!isset($s['required']))       $s['required'] = '';
 
@@ -440,6 +443,7 @@
 				url_param($s['name'],false,'name').
 				url_param($s['timeout'],false,'timeout').
 				url_param($s['url'],false,'url').
+				url_param($s['redirect'],false,'redirect').
 				url_param($s['posts'],false,'posts').
 				url_param($s['required'],false,'required').
 				url_param($s['status_codes'],false,'status_codes').
--- frontends/php/include/locales/en_gb.inc.php.orig	2009-06-16 08:12:36.000000000 -0500
+++ frontends/php/include/locales/en_gb.inc.php	2009-07-30 19:56:41.834172387 -0500
@@ -137,6 +137,7 @@
 	'S_POST'=>					'Post',
 	'S_REQUIRED'=>					'Required',
 	'S_STEP_OF_SCENARIO'=>				'Step of scenario',
+	'S_REDIRECT'=>					'Redirect',
 
 //	exp_imp.php
 	'S_ELEMENT'=>				'Element',
--- frontends/php/popup_httpstep.php.orig	2009-06-16 08:12:36.000000000 -0500
+++ frontends/php/popup_httpstep.php	2009-07-30 19:56:41.835222521 -0500
@@ -43,6 +43,7 @@
 		
 		"name"=>	array(T_ZBX_STR, O_OPT,  null,	NOT_EMPTY.KEY_PARAM(),'isset({save})'),
 		"url"=>		array(T_ZBX_STR, O_OPT,  null,	NOT_EMPTY,		'isset({save})'),
+		"redirect"=>	array(T_ZBX_STR, O_OPT,  null,	null,			null),
 		"posts"=>	array(T_ZBX_STR, O_OPT,  null,	null,			'isset({save})'),
 		"timeout"=>	array(T_ZBX_INT, O_OPT,  null,	BETWEEN(0,65535),	'isset({save})'),
 		"required"=>	array(T_ZBX_STR, O_OPT,  null,	null,			'isset({save})'),
@@ -79,7 +80,7 @@
 <script language="JavaScript" type="text/javascript">
 <!--
 
-function add_httpstep(formname,name,timeout,url,posts,required,status_codes)
+function add_httpstep(formname,name,timeout,url,redirect,posts,required,status_codes)
 {
         var form = window.opener.document.forms[formname];
 
@@ -92,6 +93,7 @@
 	add_var_to_opener_obj(form,'new_httpstep[name]',name);
 	add_var_to_opener_obj(form,'new_httpstep[timeout]',timeout);
 	add_var_to_opener_obj(form,'new_httpstep[url]',url);
+	add_var_to_opener_obj(form,'new_httpstep[redirect]',redirect);
 	add_var_to_opener_obj(form,'new_httpstep[posts]',posts);
 	add_var_to_opener_obj(form,'new_httpstep[required]',required);
 	add_var_to_opener_obj(form,'new_httpstep[status_codes]',status_codes);
@@ -107,6 +109,7 @@
 			zbx_jsvalue($_REQUEST['name']).",".
 			zbx_jsvalue($_REQUEST['timeout']).",".
 			zbx_jsvalue($_REQUEST['url']).",".
+			zbx_jsvalue((int) isset($_REQUEST['redirect'])).",".
 			zbx_jsvalue($_REQUEST['posts']).",".
 			zbx_jsvalue($_REQUEST['required']).",".
 			zbx_jsvalue($_REQUEST['status_codes']).");\n";
@@ -121,7 +124,7 @@
 <script language="JavaScript" type="text/javascript">
 <!--
 
-function update_httpstep(formname,list_name,stepid,name,timeout,url,posts,required,status_codes){
+function update_httpstep(formname,list_name,stepid,name,timeout,url,redirect,posts,required,status_codes){
 	var form = window.opener.document.forms[formname];
 	
 	if(!form){
@@ -132,6 +135,7 @@
 	add_var_to_opener_obj(form,list_name + '[' + stepid + '][name]',name);
 	add_var_to_opener_obj(form,list_name + '[' + stepid + '][timeout]',timeout);
 	add_var_to_opener_obj(form,list_name + '[' + stepid + '][url]',url);
+	add_var_to_opener_obj(form,list_name + '[' + stepid + '][redirect]',redirect);
 	add_var_to_opener_obj(form,list_name + '[' + stepid + '][posts]',posts);
 	add_var_to_opener_obj(form,list_name + '[' + stepid + '][required]',required);
 	add_var_to_opener_obj(form,list_name + '[' + stepid + '][status_codes]',status_codes);
@@ -150,6 +154,7 @@
 			zbx_jsvalue($_REQUEST['name']).",".
 			zbx_jsvalue($_REQUEST['timeout']).",".
 			zbx_jsvalue($_REQUEST['url']).",".
+			zbx_jsvalue((int) isset($_REQUEST['redirect'])).",".
 			zbx_jsvalue($_REQUEST['posts']).",".
 			zbx_jsvalue($_REQUEST['required']).",".
 			zbx_jsvalue($_REQUEST['status_codes']).");\n";
--- include/db.h.orig	2009-06-16 08:12:35.000000000 -0500
+++ include/db.h	2009-07-30 19:56:41.837168019 -0500
@@ -527,6 +527,7 @@
 	int		no;
 	char		*name;
 	char		url[MAX_STRING_LEN];	/* excessive length is required to support macros */
+	int		redirect;
 	int		timeout;
 	char		posts[MAX_STRING_LEN];
 	char		required[HTTPSTEP_REQUIRED_LEN_MAX];
--- src/zabbix_server/httppoller/httptest.c.orig	2009-06-16 08:12:35.000000000 -0500
+++ src/zabbix_server/httppoller/httptest.c	2009-07-30 19:56:41.839173582 -0500
@@ -308,13 +308,6 @@
 		(void)curl_easy_cleanup(easyhandle);
 		return;
 	}
-	if(CURLE_OK != (err = curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, 1)))
-	{
-		zabbix_log(LOG_LEVEL_ERR, "Cannot set CURLOPT_FOLLOWLOCATION [%s]",
-			curl_easy_strerror(err));
-		(void)curl_easy_cleanup(easyhandle);
-		return;
-	}
 	if(CURLE_OK != (err = curl_easy_setopt(easyhandle,CURLOPT_WRITEFUNCTION ,WRITEFUNCTION2)))
 	{
 		zabbix_log(LOG_LEVEL_ERR, "Cannot set CURLOPT_WRITEFUNCTION [%s]",
@@ -349,7 +342,7 @@
 
 	lastfailedstep=0;
 	httptest->time = 0;
-	result = DBselect("select httpstepid,httptestid,no,name,url,timeout,posts,required,status_codes from httpstep where httptestid=" ZBX_FS_UI64 " order by no",
+	result = DBselect("select httpstepid,httptestid,no,name,url,redirect,timeout,posts,required,status_codes from httpstep where httptestid=" ZBX_FS_UI64 " order by no",
 		httptest->httptestid);
 	now=time(NULL);
 	while((row=DBfetch(result)) && !err_str)
@@ -362,10 +355,11 @@
 		httpstep.no=atoi(row[2]);
 		httpstep.name=row[3];
 		strscpy(httpstep.url,row[4]);
-		httpstep.timeout=atoi(row[5]);
-		strscpy(httpstep.posts,row[6]);
-		strscpy(httpstep.required,row[7]);
-		strscpy(httpstep.status_codes,row[8]);
+		httpstep.redirect=atoi(row[5]);
+		httpstep.timeout=atoi(row[6]);
+		strscpy(httpstep.posts,row[7]);
+		strscpy(httpstep.required,row[8]);
+		strscpy(httpstep.status_codes,row[9]);
 
 		DBexecute("update httptest set curstep=%d,curstate=%d where httptestid=" ZBX_FS_UI64,
 			httpstep.no,
@@ -403,6 +397,16 @@
 		}
 		if( !err_str )
 		{
+			if(CURLE_OK != (err = curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, httpstep.redirect)))
+			{
+				zabbix_log(LOG_LEVEL_ERR, "Cannot set CURLOPT_FOLLOWLOCATION [%s]",
+					curl_easy_strerror(err));
+				err_str = strdup(curl_easy_strerror(err));
+				lastfailedstep = httpstep.no;
+			}
+		}
+		if( !err_str )
+		{
 			if(CURLE_OK != (err = curl_easy_setopt(easyhandle, CURLOPT_TIMEOUT, httpstep.timeout)))
 			{
 				zabbix_log(LOG_LEVEL_ERR, "Cannot set TIMEOUT [%s]",
