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

netty container disregards path component of baseUri #4046

Open
Chris-Lercher opened this issue Feb 1, 2019 · 1 comment
Open

netty container disregards path component of baseUri #4046

Chris-Lercher opened this issue Feb 1, 2019 · 1 comment

Comments

@Chris-Lercher
Copy link

Chris-Lercher commented Feb 1, 2019

No matter, which path component is specified in the baseUri when creating the server via org.glassfish.jersey.netty.httpserver.NettyHttpContainerProvider#createHttp2Server (probably the same for createServer?), all the resources are located relative to "/".

e.g. use a @Path("example") resource together with createHttp2Server(URI.create("http://localhost:13333/abc/"), rc, ...)

The client sees the resource wrongly located at "http://localhost:13333/example".

Using the debugger, I found the problem to be in org.glassfish.jersey.netty.httpserver.JerseyHttp2ServerHandler#createContainerRequest . The issue is, that it creates the requestUri from the baseUri + the path from the HTTP header, so it believes, the HTTP request was for "http://localhost:13333/abc/example".

Note: Please compare this with GrizzlyHttpServerFactory.createHttpServer(URI.create("http://localhost:13333/abc/", rc, ...), which behaves correctly. (There, the client sees the resource at "http://localhost:13333/abc/example")

Versions:

  • jersey-container-netty-http version 2.28
  • jersey-container-grizzly2-http 2.28
@tqh
Copy link

tqh commented May 9, 2019

I agree See

URI requestUri = URI.create(baseUri + ContainerUtils.encodeUnsafeCharacters(s));

To me it seems like there are two bugs in that line:

  • baseURI contains a path, but the incoming request path (s) is a full path so now you have the basepath twice.
  • The request url is also encoding chars with a function to encode query part only. Not sure if this is safe or not, but if it is safe it probably should have a clarification. URIBuilder would seem like a better option here.

mcserra added a commit to mcserra/jersey that referenced this issue Feb 2, 2020
Signed-off-by: Miguel Serra <Miguel.Serra@criticaltechworks.com>
mcserra added a commit to mcserra/jersey that referenced this issue Feb 2, 2020
Signed-off-by: Miguel Serra <Miguel.Serra@criticaltechworks.com>
mcserra added a commit to mcserra/jersey that referenced this issue Feb 3, 2020
Signed-off-by: Miguel Serra <Miguel.Serra@criticaltechworks.com>
mcserra added a commit to mcserra/jersey that referenced this issue Feb 19, 2020
Signed-off-by: Miguel Serra <Miguel.Serra@criticaltechworks.com>
mcserra added a commit to mcserra/jersey that referenced this issue Mar 20, 2020
Signed-off-by: Miguel Serra <Miguel.Serra@criticaltechworks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants