Bug 460016 - Trailing slash added after entry point path leads to 404 not found
Summary: Trailing slash added after entry point path leads to 404 not found
Status: NEW
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 2.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-16 08:57 EST by Arnaud MERGEY CLA
Modified: 2015-02-27 11:18 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arnaud MERGEY CLA 2015-02-16 08:57:13 EST
Adding a tranling slash to entrypoint path leads to 404 not found.

For example in demo http://rap.eclipsesource.com/demo/release/workbench/app works
but http://rap.eclipsesource.com/demo/release/workbench/app/ return 404

This issue has been introduced in RWTServlet in handleRequest :

Quote:
} else if( "/".equals( request.getPathInfo() ) && "".equals( request.getServletPath() ) ) {
// /context/: root servlet, in this case path info "/" is ok
handleValidRequest( request, response );
} else {
response.sendError( SC_NOT_FOUND );
}


with trailing slash, request.getPathInfo is "/" but request.getServletPath is not "" but "/app"

before 2.3 it used to work because RWTServlet code was different 
we went through handleInvalidRequets

Quote:
if( "/".equals( request.getPathInfo() ) ) {
// In case of "http://example.com/webapp/servlet/" redirect to
// "http://example.com/webapp/servlet" (same URL without trailing slash)
String redirectUrl = createRedirectUrl( request );
response.sendRedirect( response.encodeRedirectURL( redirectUrl ) );
}


so as request.getPathInfo is "/" request were redirected to http://rap.eclipsesource.com/demo/release/workbench/app

This is related to OSGI.
Equinox http service try /app (without trailing slash), if there is nothing registered in /app/
see org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(HttpServletRequest, HttpServletResponse)
Quote:
// perfect match
if (processAlias(req, resp, alias, null))
return;

String extensionAlias = findExtensionAlias(alias);
alias = alias.substring(0, alias.lastIndexOf('/'));

// longest path match
while (alias.length() != 0) {
if (processAlias(req, resp, alias, extensionAlias))
return;
alias = alias.substring(0, alias.lastIndexOf('/'));
}

As RWTSevlet is reached by ProxyServlet with /app, it should not return 404 nn request.getServletPath() return /app in this case that is a valid path where an entrypoint has been registered.
At least if it not considered as a bug, as it worked before 2.3, this change of behavior should be documented.

There is a workaround for each entrypoint, registering a redirect servlet to entry point path for entryPoint path + "/" should work.
Comment 1 Ralf Sternberg CLA 2015-02-27 11:13:48 EST
With the introduction of root entrypoints, this redirect turned out to be problematic. We removed it in response to bug 429041.

Servers usually redirect from foo to foo/ if foo is a directory, but not the other way round. For example,

  eclipse.org/downloads
redirects to 
  eclipse.org/downloads/

but

  eclipse.org/downloads/index.php/
would not redirect to
  eclipse.org/downloads/index.php

but respond with 404 Not Found. That's why I don't consider this a bug, however, it's right that the behavior has changed. We didn't expect it to be an issue but since you stumbled upon it, I'd suggest to add a notice to the 2.3 N&N.
Comment 2 Ralf Sternberg CLA 2015-02-27 11:18:04 EST
Of course, it would be much better if we could ignore any extra path info after the servlet path. This is currently not possible as it would break access to static resources. Feel free to open an enhancement request for this topic.