Commit ab4e39da authored by Dries's avatar Dries

- Patch #283806 by mustafau: fixed bug in drupal_http_request() and added some...

- Patch #283806 by mustafau: fixed bug in drupal_http_request() and added some first drupal_http_request() tests to core.  Yay.
parent 774d0601
......@@ -436,13 +436,13 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
// Parse the URL and make sure we can handle the schema.
$uri = parse_url($url);
if (!isset($uri['scheme'])) {
$result->error = 'missing schema';
if ($uri == FALSE) {
$result->error = 'unable to parse URL';
return $result;
}
if (!isset($uri['host'])) {
$result->error = 'missing host';
if (!isset($uri['scheme'])) {
$result->error = 'missing schema';
return $result;
}
......
......@@ -112,4 +112,28 @@ class DrupalTagsHandlingTestCase extends DrupalWebTestCase {
$this->_assert(FALSE, t('Leftover tag %leftover was left over.', array('%leftover' => $leftover)));
}
}
}
\ No newline at end of file
}
/**
* Test drupal_http_request().
*/
class DrupalHTTPRequestTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo().
*/
function getInfo() {
return array(
'name' => t('Drupal HTTP request'),
'description' => t("Performs tests on Drupal's HTTP request mechanism."),
'group' => t('System')
);
}
function testDrupalHTTPRequest() {
$missing_scheme = drupal_http_request('example.com/path');
$this->assertEqual($missing_scheme->error, 'missing schema', t('Returned with missing scheme error.'));
$unable_to_parse = drupal_http_request('http:///path');
$this->assertEqual($unable_to_parse->error, 'unable to parse URL', t('Returned with unable to parse URL error.'));
}
}
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