Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add one more method to be the same standard as httpclient so it can r… #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Agoda.Frameworks.Http.AutoRestExt/ExecuteResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ private Exception BuildAggregateException()
{
if (Exceptions.Count <= 0) return null;

var sb = new StringBuilder("There are some exceptons occurred");
var sb = new StringBuilder("Exceptions: ");
foreach (var ex in Exceptions)
{
sb.Append(string.Format("\r\n - \"{0}\" -> {1}", ex.Uri, ex.Message));
sb.Append(string.Format("\r\n - \"{0}\" -> {1}", ex.Message, ex.Uri));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why you want to change this part, as it's mostly for backward compatibility (old internal component).

}

return new Exception(sb.ToString());
}
}
Expand Down
11 changes: 10 additions & 1 deletion Agoda.Frameworks.Http/RandomUrlHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ public Task<HttpResponseMessage> PutJsonAsync(string url, string json) =>
public Task<HttpResponseMessage> DeleteAsync(string url) =>
SendAsync(url, uri => HttpClient.DeleteAsync(uri));

public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
return await SendAsync(request.RequestUri.PathAndQuery, (url) =>
{
request.RequestUri = new Uri(url);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good trick for replacing URL, but it does not look straightforward. Please add unit test for that.

Additionally, please put this method into #if !NET462 block. HttpRequestMessage cannot be reused for netframework.

return HttpClient.SendAsync(request, cancellationToken);
});
}

public Task<HttpResponseMessage> SendAsync(
string url,
Func<string, HttpRequestMessage> requestMsg) =>
Expand Down Expand Up @@ -155,7 +164,7 @@ private Task<IReadOnlyList<RetryActionResult<string, HttpResponseMessage>>> Send
{
throw new TransientHttpRequestException(
url,
combinedUrl,
combinedUrl,
res,
$"Response status code does not indicate success: ${res.StatusCode}");
}
Expand Down