This commit is contained in:
Mikael Mengistu 2017-04-28 14:37:09 -07:00 committed by GitHub
parent db868af8d8
commit 186c411f43
3 changed files with 2 additions and 8 deletions

View File

@ -18,9 +18,6 @@ namespace Microsoft.AspNetCore.Sockets.Client
{ {
public class LongPollingTransport : ITransport public class LongPollingTransport : ITransport
{ {
private static readonly string DefaultUserAgent = "Microsoft.AspNetCore.SignalR.Client/0.0.0";
private static readonly ProductInfoHeaderValue DefaultUserAgentHeader = ProductInfoHeaderValue.Parse(DefaultUserAgent);
private readonly HttpClient _httpClient; private readonly HttpClient _httpClient;
private readonly ILogger _logger; private readonly ILogger _logger;
private IChannelConnection<SendMessage, Message> _application; private IChannelConnection<SendMessage, Message> _application;
@ -90,7 +87,7 @@ namespace Microsoft.AspNetCore.Sockets.Client
while (!cancellationToken.IsCancellationRequested) while (!cancellationToken.IsCancellationRequested)
{ {
var request = new HttpRequestMessage(HttpMethod.Get, pollUrl); var request = new HttpRequestMessage(HttpMethod.Get, pollUrl);
request.Headers.UserAgent.Add(DefaultUserAgentHeader); request.Headers.UserAgent.Add(SendUtils.DefaultUserAgentHeader);
var response = await _httpClient.SendAsync(request, cancellationToken); var response = await _httpClient.SendAsync(request, cancellationToken);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();

View File

@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Sockets.Client
internal static class SendUtils internal static class SendUtils
{ {
private static readonly string DefaultUserAgent = "Microsoft.AspNetCore.SignalR.Client/0.0.0"; private static readonly string DefaultUserAgent = "Microsoft.AspNetCore.SignalR.Client/0.0.0";
private static readonly ProductInfoHeaderValue DefaultUserAgentHeader = ProductInfoHeaderValue.Parse(DefaultUserAgent); public static readonly ProductInfoHeaderValue DefaultUserAgentHeader = ProductInfoHeaderValue.Parse(DefaultUserAgent);
public static async Task SendMessages(Uri sendUrl, IChannelConnection<SendMessage, Message> application, HttpClient httpClient, CancellationTokenSource transportCts, ILogger logger) public static async Task SendMessages(Uri sendUrl, IChannelConnection<SendMessage, Message> application, HttpClient httpClient, CancellationTokenSource transportCts, ILogger logger)
{ {

View File

@ -16,9 +16,6 @@ namespace Microsoft.AspNetCore.Sockets.Client
{ {
public class ServerSentEventsTransport : ITransport public class ServerSentEventsTransport : ITransport
{ {
private static readonly string DefaultUserAgent = "Microsoft.AspNetCore.SignalR.Client/0.0.0";
private static readonly ProductInfoHeaderValue DefaultUserAgentHeader = ProductInfoHeaderValue.Parse(DefaultUserAgent);
private readonly HttpClient _httpClient; private readonly HttpClient _httpClient;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly CancellationTokenSource _transportCts = new CancellationTokenSource(); private readonly CancellationTokenSource _transportCts = new CancellationTokenSource();