Commit modifies safe session middleware to return an 401 in case of authentication failure and lack of 'text/html' in Accept header.
Previously, the middleware would always redirect to login in case of auth failure, but this was deemed inappropriate for any requests that are not top-level page navigation requests(we check this by seeming if 'text/html' is precent in Accept header)
Co-authored-by: Robert Raposa <rraposa@edx.org>