Updated for http basic authentication. Need to refactor.