summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-12-20 08:57:55 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-12-20 08:57:55 +0000
commite6a4b82e6e40a2346fd32eb63b0f8a47bf670257 (patch)
tree5de568c32cd176bbaffe58a7809ae76bf421c6f3 /includes
parentd8bd6cf97c7afce67b0b99817ccc139c65bc1c63 (diff)
downloadbrdo-e6a4b82e6e40a2346fd32eb63b0f8a47bf670257.tar.gz
brdo-e6a4b82e6e40a2346fd32eb63b0f8a47bf670257.tar.bz2
#196535 by sun, chx, dww: check whether Drupal can issue HTTP requests at all, so we know that this is the cause of problems, not the remote host not responding.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc20
-rw-r--r--includes/xmlrpc.inc1
2 files changed, 19 insertions, 2 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 82de30b39..ecbc3dfff 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -415,7 +415,23 @@ function drupal_access_denied() {
* data and redirect status.
*/
function drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
+ static $self_test = FALSE;
$result = new stdClass();
+ // Try to clear the drupal_http_request_fails variable if it's set. We
+ // can't tie this call to any error because there is no surefire way to
+ // tell whether a request has failed, so we add the check to places where
+ // some parsing has failed.
+ if (!$self_test && variable_get('drupal_http_request_fails', FALSE)) {
+ $self_test = TRUE;
+ $works = module_invoke('system', 'check_http_request');
+ $self_test = FALSE;
+ if (!$works) {
+ // Do not bother with further operations if we already know that we
+ // have no chance.
+ $result->error = t("The server can't issue HTTP requests");
+ return $result;
+ }
+ }
// Parse the URL and make sure we can handle the schema.
$uri = parse_url($url);
@@ -439,8 +455,8 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
// Make sure the socket opened properly.
if (!$fp) {
- // When a network error occurs, we make sure that it is a negative number so
- // it can clash with the HTTP status codes.
+ // When a network error occurs, we use a negative number so it does not
+ // clash with the HTTP status codes.
$result->code = -$errno;
$result->error = trim($errstr);
return $result;
diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc
index ebd19c461..6dd79b8c3 100644
--- a/includes/xmlrpc.inc
+++ b/includes/xmlrpc.inc
@@ -350,6 +350,7 @@ function xmlrpc_error($code = NULL, $message = NULL) {
$xmlrpc_error->is_error = TRUE;
$xmlrpc_error->code = $code;
$xmlrpc_error->message = $message;
+ module_invoke('system', 'check_http_request');
}
return $xmlrpc_error;
}