ariya/phantomjs — pull request #329 by rhoot (2012-10-17 01:40:29+00:00)
Title: Added a max authentication attempts option.

When QTWebKit receives a 401 code, it "loops" infinitely calling authenticationRequired until authentication succeeds (see [QNetworkAccessManager::authenticationRequired](http://doc.qt.digia.com/4.6/qnetworkaccessmanager.html#authenticationRequired)). This causes a problem with code such as:

```coffeescript
page.onRequestReceived = (request) ->
assert request.status is 401
page.open 'http://test.webdav.org/auth-basic/', (status) ->
assert status is 'fail'
```

This pull request adds a page setting `maxAuthAttempts` (defaults to 3) that limits the amount of times authentication is attempted before the request is aborted and callbacks are invoked.

Note that some special handling is included to set status to `401` and statusText to `Authorization Required` before handling the result. This since the status and statusText supplied to authorizationRequired are null.