Commit 73356fde authored by webchick's avatar webchick

#296310 by DamZ: Fixes to drupal_http_request() and accompanying tests.

parent e5b0e5f7
......@@ -563,8 +563,8 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
$location = $result->headers['Location'];
if ($retry) {
$result = drupal_http_request($result->headers['Location'], $headers, $method, $data, --$retry);
$result->redirect_code = $result->code;
$result = drupal_http_request($location, $headers, $method, $data, --$retry);
$result->redirect_code = $code;
}
$result->redirect_url = $location;
......
......@@ -168,7 +168,7 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase {
function testDrupalHTTPRequestRedirect() {
$redirect_301 = drupal_http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array(), 'GET', NULL, 1);
$this->assertEqual($redirect_301->redirect_code, 200, t('drupal_http_request follows the 301 redirect.'));
$this->assertEqual($redirect_301->redirect_code, 301, t('drupal_http_request follows the 301 redirect.'));
$redirect_301 = drupal_http_request(url('system-test/redirect/301', array('absolute' => TRUE)), array(), 'GET', NULL, 0);
$this->assertFalse(isset($redirect_301->redirect_code), t('drupal_http_request does not follow 301 redirect if $retry = 0.'));
......@@ -183,13 +183,13 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase {
$this->assertEqual($redirect_invalid->error, 'invalid schema ftp', t('301 redirect to invalid URL returned with error "!error".', array('!error' => $redirect_invalid->error)));
$redirect_302 = drupal_http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array(), 'GET', NULL, 1);
$this->assertEqual($redirect_302->redirect_code, 200, t('drupal_http_request follows the 302 redirect.'));
$this->assertEqual($redirect_302->redirect_code, 302, t('drupal_http_request follows the 302 redirect.'));
$redirect_302 = drupal_http_request(url('system-test/redirect/302', array('absolute' => TRUE)), array(), 'GET', NULL, 0);
$this->assertFalse(isset($redirect_302->redirect_code), t('drupal_http_request does not follow 302 redirect if $retry = 0.'));
$redirect_307 = drupal_http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array(), 'GET', NULL, 1);
$this->assertEqual($redirect_307->redirect_code, 200, t('drupal_http_request follows the 307 redirect.'));
$this->assertEqual($redirect_307->redirect_code, 307, t('drupal_http_request follows the 307 redirect.'));
$redirect_307 = drupal_http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array(), 'GET', NULL, 0);
$this->assertFalse(isset($redirect_307->redirect_code), t('drupal_http_request does not follow 307 redirect if $retry = 0.'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment