diff options
author | Alex <[email protected]> | 2019-01-17 01:12:16 -0800 |
---|---|---|
committer | Alex <[email protected]> | 2019-01-17 01:12:16 -0800 |
commit | 76481e3e0cc83bc7ef843b8ee5cb6bbe02f4bd9c (patch) | |
tree | fff53aa76166f7d0e6da782b1ba90938c878c77f /src | |
parent | effd1cd2922ca4faabb60f02870a8e40130db329 (diff) |
Try to fix $_SERVER data between requests
Diffstat (limited to 'src')
-rw-r--r-- | src/PSR7Client.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/PSR7Client.php b/src/PSR7Client.php index e0be34a2..350637e2 100644 --- a/src/PSR7Client.php +++ b/src/PSR7Client.php @@ -32,6 +32,8 @@ class PSR7Client /*** @var UploadedFileFactoryInterface */ private $uploadsFactory; + private $originalServer = []; + /** @var array Valid values for HTTP protocol version */ private static $allowedVersions = ['1.0', '1.1', '2',]; @@ -51,6 +53,7 @@ class PSR7Client $this->requestFactory = $requestFactory ?? new Diactoros\ServerRequestFactory(); $this->streamFactory = $streamFactory ?? new Diactoros\StreamFactory(); $this->uploadsFactory = $uploadsFactory ?? new Diactoros\UploadedFileFactory(); + $this->originalServer = $_SERVER; } /** @@ -129,6 +132,8 @@ class PSR7Client $response->getBody()->__toString(), json_encode(['status' => $response->getStatusCode(), 'headers' => $headers]) ); + + $_SERVER = $this->originalServer; } /** @@ -140,7 +145,7 @@ class PSR7Client */ protected function configureServer(array $ctx): array { - $server = $_SERVER; + $server = $this->originalServer; $server['REQUEST_TIME'] = time(); $server['REQUEST_TIME_FLOAT'] = microtime(true); $server['REMOTE_ADDR'] = $ctx['attributes']['ipAddress'] ?? $ctx['remoteAddr'] ?? '127.0.0.1'; |