2

Background: I have a Java webserver class (NanoHTTPD) which my application extends by adding sessions, page templates, authentication, and dynamic content. I wanted to make the application self contained and not rely on anything but SQLite. It is meant to run with only Java and SQLite installed.

Now for my problem. I am testing a simple index page with only Logout link. If a user goes to the index without logging in, they are HTTP redirected to the Login page. When they POST the credentials and are validated, it returns them to the index page. If you click the Logout link in Firefox, my application only receives a URI to the index('/'). Following the same process in Chrome it logs the user out as expected. I do no modify the GET URL at any point; I only run uri.equals("/logout/"). Is there any reason why Firefox would interpret this link differently?

Login HTML:

    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
    <html>
      <head>
        <title>Login</title>
      </head>
      <body>
        <h1>Login</h1>
        <div>
          <p></p>
          <form method="post" action="/login/">
            <table>
              <tr>
                <td>
                  <label for="username">Username</label>
                  <input type="text" name="username" id="username" maxlength="100" />
                </td>
                <td>
                  <label for="password">Password</label>
                  <input type="password" name="password" id="password" />
                </td>
                <td></td>
                <td>
                  <input type="submit" value="Sign In" />
                </td>
              </tr>
            </table>
          </form>
        </div>
      </body>
    </html>

Index HTML:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <title>Index</title>
      </head>
      <body>
        <h1>Index</h1>
        <a href="/logout/">Logout</a>
      </body>
    </html>

The code for matching URL's is just .equals() and the only code running before this is NanoHTTPD which is located here: https://github.com/elonen/nanohttpd/blob/master/NanoHTTPD.java

One more thing, I have made a page, "test.html", to which I copied the source from above. Firefox does not handle it correctly either and stays on the page without giving a File Not Found error. Additionally, if I change the page to use "/logout1/", everything works.

Stephan
  • 41,764
  • 65
  • 238
  • 329
Eric
  • 21
  • 1
  • It sounds like there's a cached version from earlier in your development in the Firefox cache, no? Have you tried clearing cache there and trying again? – Boris Zbarsky Dec 14 '12 at 09:31
  • Yes I have. I have also tried this on another computer and operating system. Firefox has the same issue and Chrome works fine. I have intercepted the headers of the request from Firefox and it is requesting "/", not "/logout/". I'm thinking about just changing "logout" to "signout" since that works. I'd really like to find the problem though. – Eric Dec 17 '12 at 16:42
  • 1
    I found the problem and solution thanks to your comment above. It had to do with the way Firefox was caching. It saved the redirect from the logout page and executed that. Having the no-cache in the didn't fix it. Since it was a header redirect, I had to send the no-cache in the headers. What is funny is that it would affect html files in my filesystem too, not just on the server. I'm going to track this down some more and see if I need to post a bug about Firefox's cache handling. – Eric Dec 17 '12 at 20:48
  • It really depends on the redirect you were using. Some redirects are cacheable per spec, some are not... – Boris Zbarsky Dec 17 '12 at 22:54

0 Answers0