* Copyright (C) 2010, StatusNet, Inc.
*
* A remote, atompub-receiving service
- *
+ *
* PHP version 5
*
* This program is free software: you can redistribute it and/or modify
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class ActivitySink
{
protected $svcDocUrl = null;
break;
}
}
+
if (!$takesEntries) {
continue;
}
$client->setBody($activity->asString(true, true, true));
$response = $client->send();
+
+ $status = $response->getStatus();
+ $reason = $response->getReasonPhrase();
+
+ if ($status >= 200 && $status < 300) {
+ return true;
+ } else if ($status >= 400 && $status < 500) {
+ // TRANS: Client exception thrown when post to collection fails with a 400 status.
+ // TRANS: %1$s is a URL, %2$s is the status, %s$s is the fail reason.
+ throw new ClientException(sprintf(_m('URLSTATUSREASON','%1$s %2$s %3$s'), $url, $status, $reason));
+ } else if ($status >= 500 && $status < 600) {
+ // TRANS: Server exception thrown when post to collection fails with a 500 status.
+ // TRANS: %1$s is a URL, %2$s is the status, %s$s is the fail reason.
+ throw new ServerException(sprintf(_m('URLSTATUSREASON','%1$s %2$s %3$s'), $url, $status, $reason));
+ } else {
+ // That's unexpected.
+ // TRANS: Exception thrown when post to collection fails with a status that is not handled.
+ // TRANS: %1$s is a URL, %2$s is the status, %s$s is the fail reason.
+ throw new Exception(sprintf(_m('URLSTATUSREASON','%1$s %2$s %3$s'), $url, $status, $reason));
+ }
}
}