From fe7f50ba8bbfe6605552837e20aeaeaf08a28ac5 Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Sun, 16 Oct 2016 00:36:59 +0200 Subject: [PATCH 1/3] Replaced function call with language construct (is_null), closes #12 --- src/Defaults/RequestInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Defaults/RequestInfo.php b/src/Defaults/RequestInfo.php index 828c988..4838aa3 100644 --- a/src/Defaults/RequestInfo.php +++ b/src/Defaults/RequestInfo.php @@ -63,7 +63,7 @@ public function getMethod() : string { $method = $this->get( 'REQUEST_METHOD' ); - if ( !is_null( $method ) ) + if ( null !== $method ) { return strtoupper( $method ); } @@ -77,7 +77,7 @@ public function getUri() : string { $uri = $this->get( 'REQUEST_URI' ); - if ( !is_null( $uri ) ) + if ( null !== $uri ) { return preg_replace( ['#\/+#', '#\?.*$#'], ['/', ''], $uri ); } From 6e53cc9faf25104ce40895cdae3c7894b78aa1cd Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Sun, 16 Oct 2016 00:51:09 +0200 Subject: [PATCH 2/3] Made HTTPS check case insensitive, closes #13 --- src/Defaults/RequestInfo.php | 4 +++- tests/Unit/Defaults/RequestInfoTest.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Defaults/RequestInfo.php b/src/Defaults/RequestInfo.php index 4838aa3..2780683 100644 --- a/src/Defaults/RequestInfo.php +++ b/src/Defaults/RequestInfo.php @@ -39,7 +39,9 @@ public static function fromEnv() : self public function isSecure() : bool { - return ($this->get( 'HTTPS' ) == 'on'); + $httpsValue = $this->get( 'HTTPS' ) ? : ''; + + return (strcasecmp( $httpsValue, 'on' ) === 0); } /** diff --git a/tests/Unit/Defaults/RequestInfoTest.php b/tests/Unit/Defaults/RequestInfoTest.php index 542ffdd..bb696bc 100644 --- a/tests/Unit/Defaults/RequestInfoTest.php +++ b/tests/Unit/Defaults/RequestInfoTest.php @@ -117,4 +117,17 @@ public function requestMethodProvider() ['pOSt', 'POST'], ]; } + + public function testHttpsIsCheckedCaseInsensitive() + { + $requestInfo1 = new RequestInfo( ['HTTPS' => 'On'] ); + $requestInfo2 = new RequestInfo( ['HTTPS' => 'on'] ); + $requestInfo3 = new RequestInfo( ['HTTPS' => 'oN'] ); + $requestInfo4 = new RequestInfo( ['HTTPS' => 'ON'] ); + + $this->assertTrue( $requestInfo1->isSecure() ); + $this->assertTrue( $requestInfo2->isSecure() ); + $this->assertTrue( $requestInfo3->isSecure() ); + $this->assertTrue( $requestInfo4->isSecure() ); + } } From 90385454c28f0b6351cf12d54785c99f85d1bca6 Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Sun, 16 Oct 2016 00:58:50 +0200 Subject: [PATCH 3/3] Added changelog entry regarding #13 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0055802..d6ecb62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com). +## [2.0.1] - 2016-10-16 + +### Changed + +- Check for `HTTPS = On` is now case insensitive (`RequestInfo::isSecure()`) + ## [2.0.0] - 2016-10-06 ### Added @@ -165,6 +171,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CH - First release +[2.0.1]: https://github.com/icehawk/icehawk/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/icehawk/icehawk/compare/v2.0.0-rc5...v2.0.0 [2.0.0-rc5]: https://github.com/icehawk/icehawk/compare/v2.0.0-rc4...v2.0.0-rc5 [2.0.0-rc4]: https://github.com/icehawk/icehawk/compare/v1.4.2...v2.0.0-rc4