aboutsummaryrefslogtreecommitdiffstats
path: root/Responder.php
diff options
context:
space:
mode:
Diffstat (limited to 'Responder.php')
-rw-r--r--Responder.php29
1 files changed, 20 insertions, 9 deletions
diff --git a/Responder.php b/Responder.php
index fc4f43b..749bff9 100644
--- a/Responder.php
+++ b/Responder.php
@@ -176,6 +176,7 @@ class Responder extends Connection
* @throws \Hoa\Fastcgi\Exception\CannotMultiplex
* @throws \Hoa\Fastcgi\Exception\Overloaded
* @throws \Hoa\Fastcgi\Exception\UnknownRole
+ * @throws \Hoa\Fastcgi\Exception\UnknownStatus
*/
public function send(array $headers, $content = null)
{
@@ -234,12 +235,14 @@ class Responder extends Connection
$client->disconnect();
- switch (ord($handle[parent::HEADER_CONTENT][4])) {
+ $status = ord($handle[parent::HEADER_CONTENT][4]);
+
+ switch ($status) {
case self::STATUS_CANNOT_MULTIPLEX:
throw new Exception\CannotMultiplex(
'Application %s that you are trying to reach does not ' .
'support multiplexing.',
- 0,
+ 1,
$this->getClient()->getSocket()->__toString()
);
@@ -248,7 +251,7 @@ class Responder extends Connection
case self::STATUS_OVERLOADED:
throw new Exception\Overloaded(
'Application %s is too busy and rejects your request.',
- 1,
+ 2,
$this->getClient()->getSocket()->__toString()
);
@@ -257,17 +260,25 @@ class Responder extends Connection
case self::STATUS_UNKNOWN_ROLE:
throw new Exception\UnknownRole(
'Server for the application %s returns an unknown role.',
- 2,
+ 3,
$this->getClient()->getSocket()->__toString()
);
break;
- }
- /**
- * default: // self::STATUS_COMPLETE
- * break;
- */
+ case self::STATUS_COMPLETE:
+ break;
+
+ default:
+ throw new Exception\UnknownStatus(
+ 'Server for the application %s returns an unknown status: %d.',
+ 4,
+ [
+ $this->getClient()->getSocket()->__toString(),
+ $status
+ ]
+ );
+ }
$pos = strpos($response, "\r\n\r\n");
$headers = substr($response, 0, $pos);