<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi,<br>
      <br>
      I'm using Undertow 1.2.12.Final (for its Java 7 compatibility).</p>
    <p>Let's says I have an <i>exact </i>path "/aaa/bbb" for which I
      want to chain two handlers managed by two PathHandlers:<br>
    </p>
    <p>- a SecurityInitialHandler<br>
      - a ResourceHandler<br>
      <br>
      In other words, the "/aaa/bbb" exact path is a static resource and
      is protected.<br>
    </p>
    <p>The problem I found is that if the first PathHandler (the one for
      the SecurityInitialHandler) matches, then this code is called, in
      io.undertow.server.handlers.PathHandler#handleRequest(...) :<br>
      <br>
      <i>exchange.setRelativePath(match.getRemaining());</i></p>
    <p>The "/aaa/bbb" path fully matches so the exchange's relativePath
      is set to "" after that match.<br>
      <br>
      Then, the seconds PathHandler (the one for ResourceHandler) is
      run. The matching is done using:<br>
      <br>
      <i>match = pathMatcher.match(exchange.getRelativePath());</i><br>
      <br>
      Since the relative path is now "", and not "/aaa/bbb", the
      ResourceHandler for "/aaa/bbb" is not used, even if it exists.<br>
      <br>
      Worst, since the relative path is now "", the path to match will
      actually be converted to "/". This is because of
      io.undertow.util.PathMatcher#getExactPath(...) :<br>
      <br>
      <i>return exactPathMatches.get(URLUtils.normalizeSlashes(path));</i><br>
      <br>
      The <i>normalizeSlashes(path)</i> method convert "" to "/".<br>
      <br>
      This means that the <i>default handler</i> of the second
      PathHandler will be used for "/aaa/bbb". If the "/" static
      resource exists, it will be served instead of the "/aaa/bbb"
      resource.<br>
      <br>
      Maybe I'm missing something about PathHandlers though... Any tips?<br>
      <br>
      Thanks!<br>
      <br>
      Julien<br>
    </p>
    <p><br>
      <br>
    </p>
  </body>
</html>