158 http authentication

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