This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 59caa862aebc75c77724b053996d603e6a90b033 Author: Shad Storhaug <[email protected]> AuthorDate: Fri Nov 5 20:44:59 2021 +0700 Lucene.Net.Replicator.HttpClientBase: Factored out Execute() into a separate shared method. --- src/Lucene.Net.Replicator/Http/HttpClientBase.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Lucene.Net.Replicator/Http/HttpClientBase.cs b/src/Lucene.Net.Replicator/Http/HttpClientBase.cs index a85b719..733a700 100644 --- a/src/Lucene.Net.Replicator/Http/HttpClientBase.cs +++ b/src/Lucene.Net.Replicator/Http/HttpClientBase.cs @@ -227,11 +227,7 @@ namespace Lucene.Net.Replicator.Http req.Content = new StringContent(JToken.FromObject(entity, JsonSerializer.Create(ReplicationService.JSON_SERIALIZER_SETTINGS)) .ToString(Formatting.None), Encoding.UTF8, "application/json"); - //.NET Note: Bridging from Async to Sync, this is not ideal and we could consider changing the interface to be Async or provide Async overloads - // and have these Sync methods with their caveats. - HttpResponseMessage response = httpc.SendAsync(req).ConfigureAwait(false).GetAwaiter().GetResult(); - VerifyStatus(response); - return response; + return Execute(req); } /// <summary> @@ -241,11 +237,17 @@ namespace Lucene.Net.Replicator.Http protected virtual HttpResponseMessage ExecuteGet(string request, params string[] parameters) { EnsureOpen(); + //Note: No headers? No ContentType?... Bad use of Http? HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, QueryString(request, parameters)); + return Execute(req); + } + + private HttpResponseMessage Execute(HttpRequestMessage request) + { //.NET Note: Bridging from Async to Sync, this is not ideal and we could consider changing the interface to be Async or provide Async overloads // and have these Sync methods with their caveats. - HttpResponseMessage response = httpc.SendAsync(req).ConfigureAwait(false).GetAwaiter().GetResult(); + HttpResponseMessage response = httpc.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false).GetAwaiter().GetResult(); VerifyStatus(response); return response; }
