Don't bother reading unless you give at least a quarter of a shit about XMLHttpRequest and HTTP authentication.
Here's a stupid geek trick. The correct login information for this
is user="user", password="password". Give it the wrong password [it will say something like 401 Unauthorized, user="user", password="bogus"]. Then give it the right password and try again - it will keep sending the wrong password. This happens in both Firefox and IE; Safari has a slightly different bug.
Here's the sitch: I have an XMLHttpRequest going out to a password-protected resource. The credentials are supplied by the user and thus they are likely to be wrong some of the time. The script is designed to gracefully handle authentication failure - specifically, I want to avoid the crappy infinite HTTP authentication dialog box loop. I'd think that this issue would come up from time to time, but I guess it doesn't because this is really hairy:
XMLHttpRequest
states "If authentication fails, user agents SHOULD prompt the users for credentials."
To work around this, Paul James
suggests returning 401 Unauthorized without the mandatory WWW-Authenticate header. In theory, this tells the browser to stop trying and forget the password. The browser does, in fact, stop trying, but it also goes into a weird undefined state where it continues to issue the old [incorrect] password despite instruction to the contrary. [Safari instead puts up the dialog on the next request, even if credentials are provided.]
HTTP/1.1
states "If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information." - ie, reissue the same challenge to indicate to the browser that it should give up. As near as I can tell, not a single browser has ever done that.
HTTP/1.1 also gives us 403 Forbidden: "Authorization will not help and the request SHOULD NOT be repeated." This response has the same bizarre effects as 401 without WWW-Authenticate.
I'm actually kind of an AJAX newb, so ... does anyone have any recommendations?
- Z
I think (e:strip)'s panties were more in a bunch about being treated like a bunch of chumps in that all the other bloggers seem to think that because they live in the suburbs and offer opinions on things, they're Important, but we don't actually deserve to be told if an event is cancelled or not, because we use the Internet for social networking.
It's possible she's trying to start a flamewar because our blogs get more pageviews than hers...
My panties were fine before, but now they chafe.
Go Josh!
You have to be fucking kidding me. Who the hell is Jennifer Wutz-Lopes, anyway? Maybe I should rush out to a Starbucks in the 'burbs to meet her and find out if I care!
Nobody reads Buffalo Spree anyway. Its trite and self-aggrandizing, much like Jenny's own blog. God knows this is too laughable to pontificate about. If there wasn't a tinge of doubt in my head about the nature of (e:strip) and how much she actually knows about it, it would be my absolute pleasure to rip her a new ass for saying something so foolish.