Skip to content
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

Clarify path param (URI template) matching behavior of trailing '/' in incoming path #195

Closed
glassfishrobot opened this issue Apr 18, 2013 · 6 comments
Labels
API (Server) enhancement Adding a new feature or improving an existing one

Comments

@glassfishrobot
Copy link

glassfishrobot commented Apr 18, 2013

As mentioned in jsr356-experts:
http://java.net/projects/websocket-spec/lists/jsr356-experts/archive/2013-04/message/15

In the email http://java.net/projects/websocket-spec/lists/jsr356-experts/archive/2013-03/message/33
From: Danny Coward
Subject: Closing the gaps in the URI matching specification
Date: Mon, 18 Mar 2013 17:12:35 -0700

He gives a particular example ...

(snip)
suppose we have three endpoints and their paths:
endpoint A: /a/{var}/c
endpoint B: /a/b/c
endpoint C: /a/{var1}/{var2}
incoming URI: a/b/c matches B, not A or C, because an exact match is preferred.
incoming URI: a/d/c matches A with variable var=d, because like goldlocks, its just right
incoming URI: a/x/y/ matches C, with var1=x, var2=y
(/snip)

I have issue with In the last match of incoming path "a/x/y/" (note the trailing slash)
I feel this is a bad behavior of the matching.

A scenario to ponder this behavioral quirk.

endpoint A: "/a/{var}/c/"
endpoint B: "/a/b/c"
endpoint C: "/a/{var1}/{var2}"
endpoint D: "/a/{var1}/{var2}/{var3}"

What should the incoming path "/a/x/y/" match?
Is it endpoint C with ...
var1 = "x"
var2 = "y"
or is it endpoint D with ...
var1 = "x"
var2 = "y"
var3 = ""

I don't think it should match C as the incoming path has the trailing slash indicating another path segment.
Since we are calling this whole concept PathParam, I feel that this would keep us consistent as well.

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
Reported by joakimerdfelt

@glassfishrobot
Copy link
Author

glassfishrobot commented Apr 19, 2013

@glassfishrobot Commented
markt_asf said:
RFC3986 essentially says it is up to us how to handle trailing /.

I currently prefer the position that /a/b != /a/b/ and that /a/b/ does not match /a/{var}

This is closely aligned with how to handle //.

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
dannycoward said:
Yes I think /a/b != /a/b/, especially because some http servers in front of the websocket impl may find the difference significant.

@glassfishrobot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA WEBSOCKET_SPEC-195

@glassfishrobot
Copy link
Author

@markt-asf
Copy link
Contributor

This is covered (arguably indirectly) in the current specification text where it states:

the paths do not match if they do
not have the same number of segments, using ’/’ as the separator

That means /a/b/ can't match /a/{var} as the number of segments differ. I'll add an explicit example to the documentation.

markt-asf added a commit to markt-asf/websocket-api that referenced this issue May 15, 2020
Looking at the Tomcat unit tests I see there is an explicit test that
/a/{var} does not match /a/b/ as a result of EG discussion.

Signed-off-by: Mark Thomas <markt@apache.org>
@markt-asf markt-asf added API (Server) enhancement Adding a new feature or improving an existing one and removed Priority: Major Type: Bug labels May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API (Server) enhancement Adding a new feature or improving an existing one
Projects
None yet
Development

No branches or pull requests

2 participants