Skip to content
Snippets Groups Projects
Commit 51ce2bd5 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#245990 by Dave Reid, chx, dww: Look for the www.example.com page when a HTTP...

#245990 by Dave Reid, chx, dww: Look for the www.example.com page when a HTTP request seems to fail. Looking for the local page caused problems for people with interactive authentication, redirects, hosting added JavaScript code, and so on.
parent 1a1fde55
No related branches found
No related tags found
No related merge requests found
......@@ -468,15 +468,6 @@ 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(
......@@ -1870,20 +1861,12 @@ function _system_zonelist() {
* 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.
* Whether the www.example.com page can be requested via HTTP.
*/
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;
$result = drupal_http_request('http://www.example.com');
// If the resulting page contains RFC 2606 then we got the page we wanted.
$works = isset($result->data) && preg_match('/RFC\s+2606/', $result->data);
variable_set('drupal_http_request_fails', !$works);
return $works;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment