Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Websockets transport now creates correct url #268

Merged
merged 3 commits into from
Mar 7, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class LongPollingTransport : ITransport

public Task Running { get; private set; }

public LongPollingTransport(HttpClient httpClient)
: this(httpClient, null)
{ }

public LongPollingTransport(HttpClient httpClient, ILoggerFactory loggerFactory)
{
_httpClient = httpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ private async Task Connect(Uri url)
uriBuilder.Scheme = "wss";
}

uriBuilder.Path += "/ws";

await _webSocket.ConnectAsync(uriBuilder.Uri, _cancellationToken);
}

Expand Down
20 changes: 15 additions & 5 deletions test/Microsoft.AspNetCore.SignalR.Tests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,26 @@ public async Task WebSocketsTest()
}
}

[Fact]
public async Task ConnectionCanSendAndReceiveMessages()
public static IEnumerable<object[]> Transports
{
get
{
yield return new object[] { new WebSocketsTransport() };
yield return new object[] { new LongPollingTransport(new HttpClient()) };
}
}

[ConditionalTheory]
[OSSkipCondition(OperatingSystems.Windows, WindowsVersions.Win7, WindowsVersions.Win2008R2, SkipReason = "No WebSockets Client for this platform")]
[MemberData(nameof(Transports))]
public async Task ConnectionCanSendAndReceiveMessages(ITransport transport)
{
const string message = "Major Key";
var baseUrl = _serverFixture.BaseUrl;
var loggerFactory = new LoggerFactory();

using (var httpClient = new HttpClient())
{
var transport = new LongPollingTransport(httpClient, loggerFactory);
var connection = new ClientConnection(new Uri(baseUrl + "/echo"), loggerFactory);
try
{
Expand Down Expand Up @@ -113,10 +123,10 @@ public async Task ConnectionCanSendAndReceiveDifferentMessageSizesWebSocketsTran
var baseUrl = _serverFixture.BaseUrl;
var loggerFactory = new LoggerFactory();

var transport = new WebSocketsTransport();
var connection = new ClientConnection(new Uri(baseUrl + "/echo/ws"), loggerFactory);
var connection = new ClientConnection(new Uri(baseUrl + "/echo"), loggerFactory);
try
{
var transport = new WebSocketsTransport();
var receiveTcs = new TaskCompletionSource<byte[]>();
connection.Received += (data, messageType) => receiveTcs.SetResult(data);

Expand Down