Skip to content

Commit

Permalink
Merge pull request #14 from icehawk/development
Browse files Browse the repository at this point in the history
development
  • Loading branch information
hollodotme committed Oct 15, 2016
2 parents c301c8e + 9038545 commit d9dfebd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/Defaults/RequestInfo.php
Expand Up @@ -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);
}

/**
Expand All @@ -63,7 +65,7 @@ public function getMethod() : string
{
$method = $this->get( 'REQUEST_METHOD' );

if ( !is_null( $method ) )
if ( null !== $method )
{
return strtoupper( $method );
}
Expand All @@ -77,7 +79,7 @@ public function getUri() : string
{
$uri = $this->get( 'REQUEST_URI' );

if ( !is_null( $uri ) )
if ( null !== $uri )
{
return preg_replace( ['#\/+#', '#\?.*$#'], ['/', ''], $uri );
}
Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Defaults/RequestInfoTest.php
Expand Up @@ -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() );
}
}

0 comments on commit d9dfebd

Please sign in to comment.