Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-2771

Encoded paths from servlets fail to match resources

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 4.6.0.Final, 4.5.10.Final
    • 4.5.8.Final
    • jaxrs
    • None

      This is a followup to an issue reported on the mail list between jim_krueger and rsearls.

      The issue is that when an `@ApplicationPath` or `@Path` annotation contains a nonstandard character, it is often tricky to determine how to match it.

      For example, suppose you have:
      ```
      @ApplicationPath("/app!")
      public class MyApp extends Application { ...

      @Path("/resource")
      public class MyResource {

      @GET
      public String get()

      { return "Hello World!"; }

      ...
      ```

      When I use `curl http://localhost:9080/app!/resource` it works. But when I use `curl http://localhost:9080/app%21/resource` I get a 404 - note that "%21" should decode to "!".

      But if I change the app to:
      ```
      @ApplicationPath("/app%21")
      public class MyApp extends Application { ...
      ```

      then both curl commands fail with a 404.

      Part of this failure is because our servlet container was not decoding the path in the `@ApplicationPath` annotation. Once that was corrected, then `curl http://localhost:9080/app!/resource` always worked, but `curl http://localhost:9080/app%21/resource` always failed.

      I believe that this is because the URL from the servlet request is never decoded. So when RESTEasy attempts to match the request URL to the resource URL, it will always fail when the request URL is encoded.

      A small change to the ServletUtils class should resolve this - I will be making a pull request shortly.

              rsearls r searls
              andymc12 Andy McCright (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: