Backport Accept check from chttpd

Backport "Accept check" from chttpd to correctly handle when browser
try to access a database when they aren't logged in or need to change their login

This fixes so many bugs that have been littering the bug system for years.

The problem was that browsers over promise and we were using that to check
if it was json or html. I have another patch that is only 4 lines added and two
changed but since it was changed in chttpd I thought merging that was the best
thing.

Also if this patch doesn't get accepted I have an other solution in a form of allowing
rewrite to change headers.

This closes #283

COUCHDB-1175
COUCHDB-2435