From 7d011e422f855855fc0b65a59ea9dcbc4ab25e67 Mon Sep 17 00:00:00 2001 From: Toyin Butler Date: Wed, 30 Dec 2020 17:53:26 +0000 Subject: [PATCH 1/3] Update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5fcb261..686bad3 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,10 @@ } ], "require": { - "php": ">=7.2.0", + "php": ">=7.3.0", "psr/http-message": "^1.0", "psr/log": "^1.0", - "illuminate/http": "^6.0", + "illuminate/http": "^8.0", "neomerx/cors-psr7": "^2.0" }, "require-dev": { From 7348f6be404544000fc92063c37d80101a4ade0e Mon Sep 17 00:00:00 2001 From: Toyin Butler Date: Wed, 30 Dec 2020 19:20:25 +0000 Subject: [PATCH 2/3] Fix: Use get all headers for array --- src/Adapters/IlluminateRequestToPsr7.php | 2 +- tests/CorsMiddlewareTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapters/IlluminateRequestToPsr7.php b/src/Adapters/IlluminateRequestToPsr7.php index bf8dc2c..e99bb65 100644 --- a/src/Adapters/IlluminateRequestToPsr7.php +++ b/src/Adapters/IlluminateRequestToPsr7.php @@ -71,7 +71,7 @@ public function hasHeader($name) */ public function getHeader($name) { - return $this->request->headers->get($name, null, false); + return $this->request->headers->all($name); } /** diff --git a/tests/CorsMiddlewareTest.php b/tests/CorsMiddlewareTest.php index 6820a69..2eab7b5 100644 --- a/tests/CorsMiddlewareTest.php +++ b/tests/CorsMiddlewareTest.php @@ -135,7 +135,7 @@ public function testActualCors(): void /** @var Response $response */ $this->assertNotNull($response = $this->middleware->handle($this->request, $next)); $this->assertTrue($nextCalled); - $this->assertEquals(['value 1', 'value 2'], $response->headers->get($headerName, null, false)); + $this->assertEquals(['value 1', 'value 2'], $response->headers->all($headerName)); $this->assertEquals('expose1, expose2', $response->headers->get(CorsResponseHeaders::EXPOSE_HEADERS)); } From 2b0d0931fae200d53ccbdd7143cd73dccec74c4f Mon Sep 17 00:00:00 2001 From: Toyin Butler Date: Wed, 30 Dec 2020 19:26:54 +0000 Subject: [PATCH 3/3] laravel version 8 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e550f54..a35e904 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This package adds [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) (C The package is based on [Framework agnostic (PSR-7) CORS implementation](https://github.com/neomerx/cors-psr7). -The **current version V3** is designed for Laravel 6 or higher. If you use lower Laravel version please use **V2**. +The **current version V4** is designed for Laravel 8 or higher. If you use lower Laravel version please use **V2**. ## Install @@ -106,7 +106,7 @@ As Lumen does not support `vendor:publish` command file `vendor/neomerx/cors-ill ## Exceptions and CORS headers -When exceptions are thrown and responses are created in [Laravel/Lumen exception handlers](https://laravel.com/docs/6.x/errors) middleware will be excluded from handling responses. It means CORS middleware will not add its CORS headers to responses. For this reason CORS results (including headers) are registered in [Laravel/Lumen Container](https://laravel.com/docs/6.x/container) and made accessible from any part of your application including exception handlers. +When exceptions are thrown and responses are created in [Laravel/Lumen exception handlers](https://laravel.com/docs/8.x/errors) middleware will be excluded from handling responses. It means CORS middleware will not add its CORS headers to responses. For this reason CORS results (including headers) are registered in [Laravel/Lumen Container](https://laravel.com/docs/8.x/container) and made accessible from any part of your application including exception handlers. Code sample for reading CORS headers @@ -132,11 +132,11 @@ The following methods of class `CorsMiddleware` could be replaced in descendant Additionally a custom [AnalysisStrategyInterface](https://github.com/neomerx/cors-psr7/blob/master/src/Contracts/AnalysisStrategyInterface.php) could be injected by - overriding `getCreateAnalysisStrategyClosure` method in `ServiceProvider` for Laravel/Lumen -- using [Laravel/Lumen Container binding](https://laravel.com/docs/6.x/container) for interface `AnalysisStrategyInterface` +- using [Laravel/Lumen Container binding](https://laravel.com/docs/8.x/container) for interface `AnalysisStrategyInterface` Also custom [AnalyzerInterface](https://github.com/neomerx/cors-psr7/blob/master/src/Contracts/AnalyzerInterface.php) could be injected by - overriding `getCreateAnalyzerClosure` method in `ServiceProvider` for Laravel/Lumen -- using [Laravel/Lumen Container binding](https://laravel.com/docs/6.x/container) for interface `AnalyzerInterface` +- using [Laravel/Lumen Container binding](https://laravel.com/docs/8.x/container) for interface `AnalyzerInterface` ## Testing