Fix incorrect test for long poll and web sockets requests (#1971)
This commit is contained in:
parent
3c8c8ea8e1
commit
1ae901de3d
|
|
@ -34,7 +34,19 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
public static bool IsNegotiateRequest(HttpRequestMessage request)
|
public static bool IsNegotiateRequest(HttpRequestMessage request)
|
||||||
{
|
{
|
||||||
return request.Method == HttpMethod.Post &&
|
return request.Method == HttpMethod.Post &&
|
||||||
new UriBuilder(request.RequestUri).Path.EndsWith("/negotiate");
|
new UriBuilder(request.RequestUri).Path.EndsWith("/negotiate");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsLongPollRequest(HttpRequestMessage request)
|
||||||
|
{
|
||||||
|
return request.Method == HttpMethod.Get &&
|
||||||
|
(request.RequestUri.PathAndQuery.Contains("?id=") || request.RequestUri.PathAndQuery.Contains("&id="));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsSocketSendRequest(HttpRequestMessage request)
|
||||||
|
{
|
||||||
|
return request.Method == HttpMethod.Post &&
|
||||||
|
(request.RequestUri.PathAndQuery.Contains("?id=") || request.RequestUri.PathAndQuery.Contains("&id="));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string CreateNegotiationContent(string connectionId = "00000000-0000-0000-0000-000000000000",
|
public static string CreateNegotiationContent(string connectionId = "00000000-0000-0000-0000-000000000000",
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
{
|
{
|
||||||
OnRequest((request, next, cancellationToken) =>
|
OnRequest((request, next, cancellationToken) =>
|
||||||
{
|
{
|
||||||
if (request.Method.Equals(HttpMethod.Get) && request.RequestUri.PathAndQuery.StartsWith("/?id="))
|
if (ResponseUtils.IsLongPollRequest(request))
|
||||||
{
|
{
|
||||||
return handler(cancellationToken);
|
return handler(cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
||||||
{
|
{
|
||||||
OnRequest(async (request, next, cancellationToken) =>
|
OnRequest(async (request, next, cancellationToken) =>
|
||||||
{
|
{
|
||||||
if (request.Method.Equals(HttpMethod.Post) && request.RequestUri.PathAndQuery.StartsWith("/?id="))
|
if (ResponseUtils.IsSocketSendRequest(request))
|
||||||
{
|
{
|
||||||
var data = await request.Content.ReadAsByteArrayAsync();
|
var data = await request.Content.ReadAsByteArrayAsync();
|
||||||
return await handler(data, cancellationToken);
|
return await handler(data, cancellationToken);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue