HTTPClient would return null instead of exception
This caused $response->isOK() tests to call a function on a non-existing object, causing all hell to break loose.
This commit is contained in:
@@ -58,9 +58,14 @@ class DiscoveryHints {
|
||||
{
|
||||
$client = new HTTPClient();
|
||||
$client->setHeader('Accept', 'text/html,application/xhtml+xml');
|
||||
$response = $client->get($url);
|
||||
try {
|
||||
$response = $client->get($url);
|
||||
|
||||
if (!$response->isOk()) {
|
||||
if (!$response->isOk()) {
|
||||
return null;
|
||||
}
|
||||
} catch (HTTP_Request2_Exception $e) {
|
||||
// Any HTTPClient error that might've been thrown
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -75,10 +75,14 @@ if (have_option('--verify')) {
|
||||
print "Sending for verification to $url ...\n";
|
||||
|
||||
$client = new HTTPClient();
|
||||
$response = $client->post($url, array(), array('magic_env' => $envxml));
|
||||
try {
|
||||
$response = $client->post($url, array(), array('magic_env' => $envxml));
|
||||
|
||||
print $response->getStatus() . "\n\n";
|
||||
print $response->getBody() . "\n\n";
|
||||
print $response->getStatus() . "\n\n";
|
||||
print $response->getBody() . "\n\n";
|
||||
} catch (HTTP_Request2_Exception $e) {
|
||||
print 'Failed POST to URL '.var_export($url, true).': '.$e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (have_option('--slap')) {
|
||||
|
Reference in New Issue
Block a user