summaryrefslogtreecommitdiff
path: root/modules/system/system.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.module')
-rw-r--r--modules/system/system.module35
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/system/system.module b/modules/system/system.module
index ff8f7a0ed..4328a38ba 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -445,6 +445,15 @@ function system_menu() {
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
+ // Menu handler to test that drupal_http_request() works locally.
+ // @see system_check_http_request().
+ $items['admin/reports/request-test'] = array(
+ 'title' => 'Request test',
+ 'page callback' => 'printf',
+ 'page arguments' => array('request test'),
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
// Reports:
$items['admin/reports'] = array(
@@ -1812,6 +1821,32 @@ function _system_zonelist() {
}
/**
+ * Checks whether the server is capable of issuing HTTP requests.
+ *
+ * The function sets the drupal_http_request_fail system variable to TRUE if
+ * drupal_http_request() does not work and then the system status report page
+ * will contain an error.
+ *
+ * @return
+ * Whether the admin/reports/request-test page can be requested via HTTP
+ * and contains the same output as if called via the menu system.
+ */
+function system_check_http_request() {
+ // Check whether we can do any request at all. First get the results for
+ // a very simple page which has access TRUE set via the menu system. Then,
+ // try to drupal_http_request() the same page and compare.
+ ob_start();
+ $path = 'admin/reports/request-test';
+ menu_execute_active_handler($path);
+ $nothing = ob_get_contents();
+ ob_end_clean();
+ $result = drupal_http_request(url($path, array('absolute' => TRUE)));
+ $works = isset($result->data) && $result->data == $nothing;
+ variable_set('drupal_http_request_fails', !$works);
+ return $works;
+}
+
+/**
* Format the Powered by Drupal text.
*
* @ingroup themeable