Commit 0acded75 authored by mikeytown2's avatar mikeytown2

Issue #1994054 by mikeytown2: Followup logic cleanup.

parent cc4ea729
......@@ -99,7 +99,7 @@ function httprl_requirements($phase) {
'value' => $t('drupal_http_request()'),
'description' => $t('Your system or network configuration does not allow Drupal to access web pages. This could be due to your webserver configuration or PHP settings. Debug info: !debug <br />For more info go here: <a href="!link">"HTTP request status Fails" error</a>', array(
'!link' => 'http://drupal.org/node/588186',
'!debug' => '<pre>' . print_r($_httprl['install']['debug'], TRUE) . '</pre>',
'!debug' => httprl_pr($_httprl['install']['debug'], TRUE),
)
),
);
......@@ -110,7 +110,7 @@ function httprl_requirements($phase) {
'severity' => REQUIREMENT_ERROR,
'value' => $t('Problem with stream_select()'),
'description' => $t('This server can not issue self http requests with stream_select(). Debug info: !debug <br />', array(
'!debug' => '<pre>' . print_r($_httprl['install']['debug'], TRUE) . '</pre>',
'!debug' => httprl_pr($_httprl['install']['debug'], TRUE),
)
),
);
......@@ -121,7 +121,7 @@ function httprl_requirements($phase) {
'severity' => REQUIREMENT_WARNING,
'value' => $t('This server does not handle hanging connections.'),
'description' => $t('Using non blocking mode on this server may not work correctly. Debug info: !debug <br />', array(
'!debug' => '<pre>' . print_r($_httprl['install']['debug'], TRUE) . '</pre>',
'!debug' => httprl_pr($_httprl['install']['debug'], TRUE),
)
),
);
......@@ -167,32 +167,42 @@ function httprl_install_http_test($mode, $blocking = FALSE) {
global $conf, $_httprl;
$id = 'httprl_' . hash('sha512', mt_rand() . microtime(TRUE));
// Set the headers to point to this hostname.
$headers = array(
'Host' => $_SERVER['HTTP_HOST'],
'Connection' => 'closed',
);
$args = array(
array(
'function' => 'httprl_lock_release',
'return' => '',
// Setup options array.
'options' => array(
'blocking' => $blocking,
'timeout' => 6,
'max_redirects' => 3,
'timeout' => 7,
'max_redirects' => 0,
'headers' => $headers,
),
),
$id,
);
$args_copy = $args;
// Start the timer & get a lock.
// Get a lock & start the timer.
lock_acquire($id, $args[0]['options']['timeout']);
timer_start($id);
lock_acquire($id, 6);
if ($mode == 2) {
// Queue up the request.
if ($blocking) {
$args[0]['return'] = '';
$args[0]['printed'] = '';
}
$url = httprl_queue_background_callback($args);
$url = array_keys($url);
$url = array_pop($url);
// Execute request.
httprl_send_request();
$output = httprl_send_request();
}
else {
// Get options.
......@@ -201,11 +211,6 @@ function httprl_install_http_test($mode, $blocking = FALSE) {
// Build URL to point to httprl_async_function_callback on this server.
$url = httprl_build_url_self('httprl_async_function_callback?count=0', TRUE);
// Set the headers to point to this hostname.
$headers = array(
'Host' => $_SERVER['HTTP_HOST'],
);
// Create lock name for this run.
$available = FALSE;
$lock_counter = 0;
......@@ -236,22 +241,24 @@ function httprl_install_http_test($mode, $blocking = FALSE) {
// Execute the request using core.
if (defined('VERSION') && substr(VERSION, 0, 1) >= 7) {
drupal_http_request($url, $options);
$output = drupal_http_request($url, $options);
}
else {
drupal_http_request($url, $options['headers'], $options['method'], $options['data'], $options['max_redirects'], $options['timeout']);
$output = drupal_http_request($url, $options['headers'], $options['method'], $options['data'], $options['max_redirects'], $options['timeout']);
}
}
// Wait for the lock and stop the timer.
lock_wait($id);
while (lock_wait($id)) {
usleep(25000);
}
$time = timer_stop($id);
// Add in debugging info.
$time['mode'] = $mode;
$time['blocking'] = $blocking;
$time['url'] = $url;
$time['args'] = $args_copy;
$time['request'] = $output;
$_httprl['install']['debug'][] = $time;
// See if the request came back in under 5 seconds, or if it timed out.
......@@ -259,7 +266,11 @@ function httprl_install_http_test($mode, $blocking = FALSE) {
$ip = variable_get('httprl_server_addr', FALSE);
if (empty($ip)) {
$conf['httprl_server_addr'] = -1;
return httprl_install_http_test($mode, $blocking);
$return = httprl_install_http_test($mode, $blocking);
if (!$return) {
$conf['httprl_server_addr'] == FALSE;
}
return $return;
}
else {
return FALSE;
......
......@@ -220,7 +220,6 @@ function httprl_override_core($url, $options) {
*/
function httprl_build_url_self($path = '', $detect_schema = FALSE) {
global $base_path, $conf;
static $variable_loaded = FALSE;
if (!empty($base_path)) {
$root_path = $base_path;
......@@ -2365,7 +2364,7 @@ function httprl_get_server_schema() {
/**
* Send out a fast 403 and exit.
*/
function httprl_fast403() {
function httprl_fast403($msg = '') {
global $base_path;
// Set headers.
......@@ -2381,7 +2380,7 @@ function httprl_fast403() {
print '<body><h1>Forbidden</h1>';
print '<p>You are not authorized to access this page.</p>';
print '<p><a href="' . $base_path . '">Home</a></p>';
print '<!-- httprl_fast403 -->';
print '<!-- httprl_fast403 ' . $msg . ' -->';
print '</body></html>';
// Exit Script.
......
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