nghttpx: "*" must match at least one character
This commit is contained in:
parent
04145e22a2
commit
4bb88b35ec
|
@ -269,10 +269,11 @@ time:
|
|||
|
||||
We can use ``*`` in the left most position of host to achieve wildcard
|
||||
suffix match. If ``*`` is the left most character, then the remaining
|
||||
string should match the request host suffix. For example,
|
||||
``*.example.com`` matches ``www.example.com`` and ``dev.example.com``,
|
||||
and does not match ``example.com`` and ``nghttp2.org``. The exact
|
||||
match (without ``*``) always takes precedence over wildcard match.
|
||||
string should match the request host suffix. ``*`` must match at
|
||||
least one character. For example, ``*.example.com`` matches
|
||||
``www.example.com`` and ``dev.example.com``, and does not match
|
||||
``example.com`` and ``nghttp2.org``. The exact match (without ``*``)
|
||||
always takes precedence over wildcard match.
|
||||
|
||||
One important thing you have to remember is that we have to specify
|
||||
default routing pattern for so called "catch all" pattern. To write
|
||||
|
|
|
@ -1225,10 +1225,11 @@ Connections:
|
|||
|
||||
Host can include "*" in the left most position to
|
||||
indicate wildcard match (only suffix match is done).
|
||||
For example, host pattern "*www.nghttp2.org" matches
|
||||
against "www.nghttp2.org" and "1www.ngttp2.org", but
|
||||
does not match against "nghttp2.org". The exact hosts
|
||||
match takes precedence over the wildcard hosts match.
|
||||
The "*" must match at least one character. For example,
|
||||
host pattern "*.nghttp2.org" matches against
|
||||
"www.nghttp2.org" and "git.ngttp2.org", but does not
|
||||
match against "nghttp2.org". The exact hosts match
|
||||
takes precedence over the wildcard hosts match.
|
||||
|
||||
If <PATTERN> is omitted or empty string, "/" is used as
|
||||
pattern, which matches all request paths (catch-all
|
||||
|
|
|
@ -321,7 +321,9 @@ size_t match_downstream_addr_group_host(
|
|||
|
||||
for (auto it = std::begin(wildcard_patterns);
|
||||
it != std::end(wildcard_patterns); ++it) {
|
||||
if (!util::ends_with(std::begin(host), std::end(host),
|
||||
/* left most '*' must match at least one character */
|
||||
if (host.size() <= (*it).host.size() ||
|
||||
!util::ends_with(std::begin(host), std::end(host),
|
||||
std::begin((*it).host), std::end((*it).host))) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ void test_shrpx_worker_match_downstream_addr_group(void) {
|
|||
wp.back().router.add_route(StringRef::from_lit("/echo/"), 11);
|
||||
wp.back().router.add_route(StringRef::from_lit("/echo/foxtrot"), 12);
|
||||
|
||||
CU_ASSERT(10 == match_downstream_addr_group(
|
||||
CU_ASSERT(11 == match_downstream_addr_group(
|
||||
router, wp, StringRef::from_lit("git.nghttp2.org"),
|
||||
StringRef::from_lit("/echo"), groups, 255));
|
||||
|
||||
|
@ -200,9 +200,9 @@ void test_shrpx_worker_match_downstream_addr_group(void) {
|
|||
router, wp, StringRef::from_lit("it.nghttp2.org"),
|
||||
StringRef::from_lit("/echo"), groups, 255));
|
||||
|
||||
CU_ASSERT(12 == match_downstream_addr_group(
|
||||
router, wp, StringRef::from_lit(".nghttp2.org"),
|
||||
StringRef::from_lit("/echo/foxtrot"), groups, 255));
|
||||
CU_ASSERT(255 == match_downstream_addr_group(
|
||||
router, wp, StringRef::from_lit(".nghttp2.org"),
|
||||
StringRef::from_lit("/echo/foxtrot"), groups, 255));
|
||||
|
||||
CU_ASSERT(9 == match_downstream_addr_group(
|
||||
router, wp, StringRef::from_lit("alpha.nghttp2.org"),
|
||||
|
|
Loading…
Reference in New Issue