Adds HTTP Basic Auth and Digest support

A somewhat cleaned up pull request merged from the latest master.