Use the net package function for credentials.

This change ensures any usernames or passwords which contain symbols that
would confuse the URL parser are properly escaped.