New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added ROUTE::OPTIONAL_SECURED #1196
Changes from all commits
6da370d
5b2fccd
10ecf1e
e417c8f
f2d7d8d
3a1f0a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,8 @@ class Route extends Nette\Object implements Application\IRouter | |
/** @var int */ | ||
private $flags; | ||
|
||
/** @var bool */ | ||
private $httpRequestSecured = false; | ||
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. Wrong coding style, should be in upper case. 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. ... |
||
|
||
/** | ||
* @param string URL mask, e.g. '<presenter>/<action>/<id \d{1,3}>' | ||
|
@@ -251,13 +253,15 @@ public function match(Nette\Http\IRequest $httpRequest) | |
unset($params[self::PRESENTER_KEY]); | ||
} | ||
|
||
$this->httpRequestSecured = $httpRequest->isSecured(); | ||
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. Please do not save the state here, it's not neccessary and makes it harder to test router. |
||
|
||
return new Application\Request( | ||
$presenter, | ||
$httpRequest->getMethod(), | ||
$params, | ||
$httpRequest->getPost(), | ||
$httpRequest->getFiles(), | ||
array(Application\Request::SECURED => $httpRequest->isSecured()) | ||
array(Application\Request::SECURED => $this->httpRequestSecured) | ||
); | ||
} | ||
|
||
|
@@ -404,7 +408,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re | |
return NULL; // TODO: implement counterpart in match() ? | ||
} | ||
|
||
$url = ($this->flags & self::SECURED ? 'https:' : 'http:') . $url; | ||
$url = ((($this->flags & self::SECURED) || (($this->flags & self::OPTIONAL_SECURED) && $this->httpRequestSecured)) ? 'https:' : 'http:') . $url; | ||
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. So this wouldn't work correctly if match() isn't called? It seems to be wrong. Also I think brackets around bitwise operations are unnecessary. 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. Do you know about case when this would be used and match() isn't called? And brackets are for visual diff of conditions 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. Imagine you have 5 routes. You open a page which is matched by first route. Other four won't have |
||
|
||
// build query string | ||
if ($this->xlat) { | ||
|
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.
OPTIONALLY_SECURED
is gramatically rightThere 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.
i will commit grammatical fix later