Currently, the HttpWebRequest task(s) support giving UserName and UserPassword as parameters to enable basic HTTP authentication (added in revision 890 by wayne.bradney). I would like to be able to use the same logic for WebClient.DownloadFile, as our build automation flow relies on querying for build artifacts through TeamCity server's REST API and downloading the latest ones.
I moved the following lines of code locally into WebClient.cs to DownloadFile and OpenRead functions, and checked that the solution works for me simply by replacing the resulting DLL, but it would be great to have official support for this as well:
if (!string.IsNullOrEmpty(this.UserName))
{
client.Credentials = new System.Net.NetworkCredential(this.UserName, this.UserPassword);
}
Currently, the HttpWebRequest task(s) support giving UserName and UserPassword as parameters to enable basic HTTP authentication (added in revision 890 by wayne.bradney). I would like to be able to use the same logic for WebClient.DownloadFile, as our build automation flow relies on querying for build artifacts through TeamCity server's REST API and downloading the latest ones.
I moved the following lines of code locally into WebClient.cs to DownloadFile and OpenRead functions, and checked that the solution works for me simply by replacing the resulting DLL, but it would be great to have official support for this as well:
if (!string.IsNullOrEmpty(this.UserName)) { client.Credentials = new System.Net.NetworkCredential(this.UserName, this.UserPassword); }
I'm attaching the file I made changes to.
WebClient.zip