Skip to content

Commit

Permalink
readded getraw method
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderfast committed Jan 8, 2013
1 parent fe0393f commit eb1ff79
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/TeamCitySharp/Connection/TeamCityCaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ private HttpClient CreateHttpClient(string userName, string password, string acc
return httpClient;
}

// only used by the artifact listing methods since i havent found a way to deserialize them into a domain entity
internal string GetRaw(string urlPart)
{
if (CheckForUserNameAndPassword())
throw new ArgumentException("If you are not acting as a guest you must supply userName and password");

if (string.IsNullOrEmpty(urlPart))
throw new ArgumentException("Url must be specfied");

var url = CreateUrl(urlPart);

var httpClient = CreateHttpClient(_configuration.UserName, _configuration.Password, HttpContentTypes.TextPlain);
var response = httpClient.Get(url);
if (IsHttpError(response))
{
throw new HttpException(response.StatusCode, string.Format("Error {0}: Thrown with URL {1}", response.StatusDescription, url));
}

return response.RawText;
}

private bool CheckForUserNameAndPassword()
{
return !_configuration.ActAsGuest && string.IsNullOrEmpty(_configuration.UserName) && string.IsNullOrEmpty(_configuration.Password);
Expand Down

0 comments on commit eb1ff79

Please sign in to comment.