-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Optimised dumped router matcher, prevent unneeded function calls. #21755
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
Changes from 1 commit
ea8c55a
0d69cfe
0425f33
56f2323
ef6ad3a
44271e0
e4a9e1e
2e180c6
9d92c57
f56cf9a
bb68154
4ab821b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,11 @@ public function match($pathinfo) | |
$trimmedPathinfo = rtrim($pathinfo, '/'); | ||
$context = $this->context; | ||
$request = $this->request; | ||
$requestMethod = $isLikeGetMethod = $context->getMethod(); | ||
$requestMethod = $canonicalMethod = $context->getMethod(); | ||
$schema = $context->getScheme(); | ||
|
||
if ('HEAD' === $requestMethod) { | ||
$isLikeGetMethod = 'GET'; | ||
$canonicalMethod = 'GET'; | ||
} | ||
|
||
|
||
|
@@ -43,7 +43,7 @@ public function match($pathinfo) | |
if (0 === strpos($pathinfo, '/bar')) { | ||
// bar | ||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { | ||
if ('GET' !== $isLikeGetMethod) { | ||
if ('GET' !== $canonicalMethod) { | ||
$allow[] = 'GET'; | ||
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. Why aren't you adding HEAD anymore here ? It is an allowed method 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. @stof this was an optimisation proposed by @fabpot. We stream HEAD in a special way (this is current behaviour). When a HEAD request is made, we also match GET. Inverted, when we declare GET actions, we also match in HEAD. So in this normalised case we know that if something is "like get" we don't need HEAD anymore because we're we already match GET. 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. Can we make sure that this is properly tested? If someone else breaks this, it will be a huge bug! 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. @Jean85 there's an additional test case added in this PR to do just that. |
||
goto not_bar; | ||
} | ||
|
@@ -54,7 +54,7 @@ public function match($pathinfo) | |
|
||
// barhead | ||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) { | ||
if ('GET' !== $isLikeGetMethod) { | ||
if ('GET' !== $canonicalMethod) { | ||
$allow[] = 'GET'; | ||
goto not_barhead; | ||
} | ||
|
@@ -91,7 +91,7 @@ public function match($pathinfo) | |
|
||
// baz5 | ||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) { | ||
if ('POST' !== $isLikeGetMethod) { | ||
if ('POST' !== $canonicalMethod) { | ||
$allow[] = 'POST'; | ||
goto not_baz5; | ||
} | ||
|
@@ -102,7 +102,7 @@ public function match($pathinfo) | |
|
||
// baz.baz6 | ||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) { | ||
if ('PUT' !== $isLikeGetMethod) { | ||
if ('PUT' !== $canonicalMethod) { | ||
$allow[] = 'PUT'; | ||
goto not_bazbaz6; | ||
} | ||
|
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.
should be
$scheme
here, not$schema
, right?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.
@fabpot correct, I've fixed it.