aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-10-20 09:17:48 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-10-20 09:17:48 +0200
commit3193ce60391468d7fa90e38bec6fd493dd2119c7 (patch)
treea6aaec631d62ef8886202acfa543dfc66f4df89e
parent1cd8c625c005a8e0005728bf2fb81b0626dd253a (diff)
parent03099824a883b50141652f160eb2aaa3790ad6a3 (diff)
downloadFastcgi-3193ce60391468d7fa90e38bec6fd493dd2119c7.zip
Fastcgi-3193ce60391468d7fa90e38bec6fd493dd2119c7.tar.gz
Fastcgi-3193ce60391468d7fa90e38bec6fd493dd2119c7.tar.bz2
Merge branch 'incoming'
-rw-r--r--Responder.php30
1 files changed, 21 insertions, 9 deletions
diff --git a/Responder.php b/Responder.php
index d21899a..749bff9 100644
--- a/Responder.php
+++ b/Responder.php
@@ -176,10 +176,12 @@ 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)
{
$this->_content = null;
+ $this->_headers = [];
$client = $this->getClient();
$client->connect();
@@ -233,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()
);
@@ -247,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()
);
@@ -256,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);