Skip to content

Commit

Permalink
Merge pull request #250 from mnapoli/fix-249
Browse files Browse the repository at this point in the history
Recreate a new Responder every time because it contains state
  • Loading branch information
mnapoli authored Feb 18, 2019
2 parents a6cbbb1 + 8c7ab95 commit 8e0b0e3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Runtime/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PhpFpm
private const SOCKET = '/tmp/.bref/php-fpm.sock';
private const CONFIG = '/opt/bref/etc/php-fpm.conf';

/** @var Responder */
/** @var Client */
private $client;
/** @var string */
private $handler;
Expand All @@ -35,9 +35,7 @@ class PhpFpm

public function __construct(string $handler, string $configFile = self::CONFIG)
{
$this->client = new Responder(
new Client('unix://' . self::SOCKET, 30000)
);
$this->client = new Client('unix://' . self::SOCKET, 30000);
$this->handler = $handler;
$this->configFile = $configFile;
}
Expand Down Expand Up @@ -100,9 +98,10 @@ public function proxy($event): LambdaResponse

[$requestHeaders, $requestBody] = $this->eventToFastCgiRequest($event);

$this->client->send($requestHeaders, $requestBody);
$responder = new Responder($this->client);
$responder->send($requestHeaders, $requestBody);

$responseHeaders = $this->client->getResponseHeaders();
$responseHeaders = $responder->getResponseHeaders();

$responseHeaders = array_change_key_case($responseHeaders, CASE_LOWER);

Expand Down Expand Up @@ -130,7 +129,7 @@ public function proxy($event): LambdaResponse
}
unset($responseHeaders['status']);

$responseBody = $this->client->getResponseContent();
$responseBody = $responder->getResponseContent();

return new LambdaResponse((int) $status, $responseHeaders, $responseBody);
}
Expand Down

0 comments on commit 8e0b0e3

Please sign in to comment.