Menu

#803 HTTP 401 Unathorised being treated as an error

Latest SVN
closed
None
5
2012-10-21
2009-03-26
No

Found this through Celerity 0.0.6. If you set throwExceptionOnFailingStatusCode = true, then HtmlUnit raises an error HTTP response code 401. 401 is not actually an error, it's a normal part of using a protected site. I think it should be treated as success code.

Discussion

  • Daniel Gredler

    Daniel Gredler - 2009-03-26

    4xx are client errors, 5xx are server errors:

    http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error

    I'm pretty sure I disagree with you, unless you have a more persuasive argument...

     
  • Ashley Moran

    Ashley Moran - 2009-03-27

    The thing is, a 401 is part of the normal login process.

    I turned on error reporting so that I get exceptions on 404s and 500s because it's more useful. For example, I don't want to see output from Cucumber/RSpec like this: 'expected "My App 500 internal sever error ... lots of text ..." to include "Thanks for signing up"'. It's makes a much more rapid BDD experience if I just see it's a 404 or 500.

    BUT - 401 is a desirable response code. I want a 401 when I try to access my app, so I know I have to log in. It's not an irrecoverable error (unlike 403 Forbidden, which is irrecoverable). But if I turn on error reporting to highlight 404 and 500 errors, that means I can't access any protected parts of my app.

    WDYT?

     
  • Daniel Gredler

    Daniel Gredler - 2009-03-28

    Can you set throwExceptionOnFailingStatusCode = false for the tests that test the 401 responses, but set it to true for all others?

    Or perhaps set it to true always, and tell your test to expect an error in the test that verifies 401s?

     

Log in to post a comment.