thoughtbot/capybara-webkit — pull request #304 by baconpat (2012-03-26 00:36:50+00:00)
Title: Fix 4.8.0 problem with select/too many open files 

This code change fixes a problem that prevents running the test suite on OS X against QT 4.8.0 (repeated *select: Invalid argument* errors until the terminal is unusable). There are still tests failing when you use 4.8.0, but at least you can run the whole suite. This problem is discussed in another pull request: https://github.com/thoughtbot/capybara-webkit/pull/263

The same problem caused "too many open files" errors when running a large test suite on Ubuntu. I believe the following two lines (from WebPage.cpp) are the culprit:

```ruby
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinished(QNetworkReply *)));
connect(manager, SIGNAL(sslErrors(QNetworkReply *, QList)), this, SLOT(ignoreSslErrors(QNetworkReply *, QList)));
```

Every time the `setCustomNetworkAccessManager` method is called those SIGNALs and SLOTs are setup, but never cleaned up. Rather than worry about that, I changed the code to keep using the same NetworkAccessManager, but added a method to reset the headers.

No new tests have been added because no new functionality has been added. Being able to run the existing test suite against 4.8.0 is the test.