aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-10-20 09:18:53 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-10-20 09:18:53 +0200
commit6458f636ceba79121c3e426922eed0a0f5a16b48 (patch)
tree455f73fb92716b2c18b79f86e8ca163d9837b077
parent1eb22f59420442c4bff1adac1e3f8a9fd5a039bb (diff)
parent3193ce60391468d7fa90e38bec6fd493dd2119c7 (diff)
downloadFastcgi-6458f636ceba79121c3e426922eed0a0f5a16b48.zip
Fastcgi-6458f636ceba79121c3e426922eed0a0f5a16b48.tar.gz
Fastcgi-6458f636ceba79121c3e426922eed0a0f5a16b48.tar.bz2
Merge branch 'master' into pr/19
-rw-r--r--Responder.php30
1 files changed, 21 insertions, 9 deletions
diff --git a/Responder.php b/Responder.php
index 2e01a37..e1c903f 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, &$stderr = '')
{
$this->_content = null;
+ $this->_headers = [];
$client = $this->getClient();
$client->connect();
@@ -236,12 +238,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()
);
@@ -250,7 +254,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()
);
@@ -259,17 +263,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);