Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

(#808) Added SendAsync support for the internal HttpClient. #810

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 22 additions & 0 deletions sdk/dotnet/src/Microsoft.Datasync.Client/DatasyncClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -301,6 +302,27 @@ public virtual async Task PushTablesAsync(IEnumerable<string> tables, PushOption
await SyncContext.PushItemsAsync(tables.ToArray(), options, cancellationToken).ConfigureAwait(false);
}

#region SendAsync
/// <summary>
/// Sends a HTTP request to the remote service, using the in-built HTTP client.
/// </summary>
/// <param name="request">The HTTP request message to send.</param>
/// <param name="completionOption">When the operation should complete (as soon as a response is available, or after reading the whole response content).</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
/// <returns>A task that returns the <see cref="HttpResponseMessage"/> for the response when complete.</returns>
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken = default)
=> HttpClient.HttpClient.SendAsync(request, completionOption, cancellationToken);

/// <summary>
/// Sends a HTTP request to the remote service, using the in-built HTTP client.
/// </summary>
/// <param name="request">The HTTP request message to send.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
/// <returns>A task that returns the <see cref="HttpResponseMessage"/> for the response when complete.</returns>
public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default)
=> HttpClient.HttpClient.SendAsync(request, cancellationToken);
#endregion

/// <summary>
/// Sends a synchronization event to the consumers.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ internal ServiceHttpClient(Uri endpoint, AuthenticationProvider authenticationPr
/// </summary>
public Uri Endpoint { get; }

/// <summary>
/// The <see cref="HttpClient"/> to use for communication.
/// </summary>
internal HttpClient HttpClient => client;

/// <summary>
/// The installation ID to send with each request.
/// </summary>
public string InstallationId { get; }

/// <summary>
Expand Down