Skip to content

Commit

Permalink
reverted modification on de 2.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
mavezeau committed May 27, 2022
1 parent b222f11 commit 031b6b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/TeamCitySharp/Connection/HttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace TeamCitySharp.Connection
{
public static class HttpClientExtensions
{
public static async Task<HttpResponseMessage> Get(this HttpClient src, string url)
public static HttpResponseMessage Get(this HttpClient src, string url)
{
//TODO: quick fix, need to fix soon for a big transaction
src.Timeout=TimeSpan.FromHours(1);
var content = await src.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);
return content;
//TODO: quick fix, need to fix soon for a big transaction
src.Timeout=TimeSpan.FromHours(1);
var content = src.GetAsync(url);
return content.GetAwaiter().GetResult();
}

public static HttpResponseMessage Post(this HttpClient src, string url, object body, string contentType)
Expand Down Expand Up @@ -50,9 +50,9 @@ public static HttpResponseMessage GetAsFile(this HttpClient src, string url, str
{
using (var response = src.Get(url))
{
response.Result.EnsureSuccessStatusCode();
response.EnsureSuccessStatusCode();

using (Stream contentStream = response.Result.Content.ReadAsStreamAsync().GetAwaiter().GetResult(),
using (Stream contentStream = response.Content.ReadAsStreamAsync().GetAwaiter().GetResult(),
fileStream = new FileStream(tempFilename, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true))
{
var buffer = new byte[8192];
Expand All @@ -71,7 +71,7 @@ public static HttpResponseMessage GetAsFile(this HttpClient src, string url, str
}
} while (isMoreToRead);

return response.Result;
return response;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/TeamCitySharp/Connection/TeamCityCaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private HttpResponseMessage GetResponse(string urlPart)
var url = CreateUrl(urlPart);

var response =
CreateHttpClient(m_credentials.UserName, m_credentials.Password, HttpContentTypes.ApplicationJson).Get(url).Result;
CreateHttpClient(m_credentials.UserName, m_credentials.Password, HttpContentTypes.ApplicationJson).Get(url);
ThrowIfHttpError(response, url);
return response;
}
Expand All @@ -181,7 +181,7 @@ public bool Authenticate(string urlPart, bool throwExceptionOnHttpError = true)
try
{
var httpClient = CreateHttpClient(m_credentials.UserName, m_credentials.Password, HttpContentTypes.TextPlain);
var response = httpClient.Get(CreateUrl(urlPart)).Result;
var response = httpClient.Get(CreateUrl(urlPart));
if (response.StatusCode != HttpStatusCode.OK && throwExceptionOnHttpError)
{
throw new AuthenticationException();
Expand Down Expand Up @@ -337,7 +337,7 @@ public string GetRaw(string urlPart, bool rest)
var url = rest ? CreateUrl(urlPart) : CreateUrl(urlPart, false);

var httpClient = CreateHttpClient(m_credentials.UserName, m_credentials.Password, HttpContentTypes.TextPlain);
var response = httpClient.Get(url).Result;
var response = httpClient.Get(url);
if (IsHttpError(response))
{
throw new HttpException(response.StatusCode,
Expand Down Expand Up @@ -381,7 +381,7 @@ public bool GetBoolean(string urlPart, params object[] parts)
var url = CreateUrl(urlFull);

var response =
CreateHttpClient(m_credentials.UserName, m_credentials.Password, HttpContentTypes.ApplicationJson).Get(url).Result;
CreateHttpClient(m_credentials.UserName, m_credentials.Password, HttpContentTypes.ApplicationJson).Get(url);
return !IsHttpError(response);
}
catch (Exception)
Expand Down

0 comments on commit 031b6b3

Please sign in to comment.