This repository was archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Added support for x-forwarded-proto header to request object #134
Closed
SteveReiter
wants to merge
3
commits into
zendframework:master
from
SteveReiter:x_forward_proto_support
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
| /** | ||
| * @see https://github.com/zendframework/zend-http for the canonical source repository | ||
| * @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com) | ||
| * @license https://github.com/zendframework/zend-http/blob/master/LICENSE.md New BSD License | ||
| */ | ||
|
|
||
| namespace Zend\Http; | ||
|
|
||
| use Zend\Uri\Http as Http; | ||
|
|
||
| class HttpsUri extends Http | ||
| { | ||
| /** | ||
| * Get the scheme part of the URI | ||
| * | ||
| * @return string|null | ||
| */ | ||
| public function getScheme() | ||
| { | ||
| return 'https'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This breaks Uri contract by ignoring scheme changes |
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| use Zend\Stdlib\RequestInterface; | ||
| use Zend\Uri\Exception as UriException; | ||
| use Zend\Uri\Http as HttpUri; | ||
| use Zend\Http\HttpsUri; | ||
|
|
||
| /** | ||
| * HTTP Request | ||
|
|
@@ -228,6 +229,11 @@ public function getUri() | |
| if ($this->uri === null || is_string($this->uri)) { | ||
| $this->uri = new HttpUri($this->uri); | ||
| } | ||
|
|
||
| $headers = $this->getHeaders()->toArray(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need all the headers. Use |
||
| if (array_key_exists('X-Forwarded-Proto', $headers) && $headers['X-Forwarded-Proto'] === 'https') { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will end up overriding scheme each time Uri is fetched from Request. Getters must not have side effects |
||
| $this->uri = new HttpsUri($this->uri); | ||
| } | ||
| return $this->uri; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reason to introduce this class.
$uri->setScheme('https');provides exactly the same behavior