Skip to content

Commit 82c09ac

Browse files
committed
make Listener\ForceHttps::setHttpStrictTransportSecurity() return response to make consistent with Expressive one
1 parent eb5dfed commit 82c09ac

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Listener/ForceHttps.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function attach(EventManagerInterface $events, $priority = 1)
4545
* @param string $uriScheme
4646
* @param mixed $match didn't typed hinted in code in favor of zf-mvc ^2.5 RouteMatch compat
4747
* @param Response $response
48+
* @return Response
4849
*/
4950
private function setHttpStrictTransportSecurity($uriScheme, $match, Response $response)
5051
{
@@ -56,19 +57,19 @@ private function setHttpStrictTransportSecurity($uriScheme, $match, Response $re
5657
$this->config['strict_transport_security']['value']
5758
)
5859
) {
59-
return;
60+
return $response;
6061
}
6162

6263
if ($this->config['strict_transport_security']['enable'] === true) {
6364
$response->getHeaders()
6465
->addHeaderLine('Strict-Transport-Security: ' . $this->config['strict_transport_security']['value']);
65-
return;
66+
return $response;
6667
}
6768

6869
// set max-age = 0 to strictly expire it,
6970
$response->getHeaders()
7071
->addHeaderLine('Strict-Transport-Security: max-age=0');
71-
return;
72+
return $response;
7273
}
7374

7475
/**
@@ -92,13 +93,11 @@ public function forceHttpsScheme(MvcEvent $e)
9293
$uriScheme = $uri->getScheme();
9394

9495
$routeMatch = $e->getRouteMatch();
95-
$this->setHttpStrictTransportSecurity($uriScheme, $routeMatch, $response);
96+
$response = $this->setHttpStrictTransportSecurity($uriScheme, $routeMatch, $response);
9697
if (! $this->validateSchemeAndToBeForcedHttpsConfig($uriScheme, $routeMatch)) {
9798
return;
9899
}
99100

100-
/** @var $response \Zend\Http\PhpEnvironment\Response */
101-
$response = $e->getResponse();
102101
$httpsRequestUri = $this->withWwwPrefixWhenRequired($uri->setScheme('https')->toString());
103102

104103
// 307 keeps headers, request method, and request body

0 commit comments

Comments
 (0)