forked from Inedo/inedox-teamcity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TeamCityWebClient.cs
23 lines (21 loc) · 946 Bytes
/
TeamCityWebClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Net;
namespace Inedo.BuildMasterExtensions.TeamCity
{
internal sealed class TeamCityWebClient : WebClient
{
public TeamCityWebClient(TeamCityConfigurer configurer)
{
this.BaseAddress = configurer.BaseUrl;
if (!string.IsNullOrEmpty(configurer.Username))
{
// Using a CredentialCache because API URLs with TeamCity variables in them will issue redirects
// to the actual URLs, and unlike the NetworkCredential class, CredentialCache will ensure that the
// credentials will be sent to the redirected URL as well
var credentials = new CredentialCache();
credentials.Add(new Uri(configurer.BaseUrl), "Basic", new NetworkCredential(configurer.Username, configurer.Password));
this.Credentials = credentials;
}
}
}
}