fix #106 by removing ReplaceFeature
This commit is contained in:
parent
b3f755dff3
commit
f58a373704
|
|
@ -40,12 +40,9 @@ namespace Microsoft.AspNetCore.WebSockets
|
|||
{
|
||||
// Detect if an opaque upgrade is available. If so, add a websocket upgrade.
|
||||
var upgradeFeature = context.Features.Get<IHttpUpgradeFeature>();
|
||||
if (upgradeFeature != null)
|
||||
if (upgradeFeature != null && context.Features.Get<IHttpWebSocketFeature>() == null)
|
||||
{
|
||||
if (_options.ReplaceFeature || context.Features.Get<IHttpWebSocketFeature>() == null)
|
||||
{
|
||||
context.Features.Set<IHttpWebSocketFeature>(new UpgradeHandshake(context, upgradeFeature, _options));
|
||||
}
|
||||
context.Features.Set<IHttpWebSocketFeature>(new UpgradeHandshake(context, upgradeFeature, _options));
|
||||
}
|
||||
|
||||
return _next(context);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ namespace Microsoft.AspNetCore.Builder
|
|||
{
|
||||
KeepAliveInterval = TimeSpan.FromMinutes(2);
|
||||
ReceiveBufferSize = 4 * 1024;
|
||||
ReplaceFeature = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -28,11 +27,5 @@ namespace Microsoft.AspNetCore.Builder
|
|||
/// The default is 4kb.
|
||||
/// </summary>
|
||||
public int ReceiveBufferSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the middleware should replace the WebSocket implementation provided by
|
||||
/// a component earlier in the stack. This is false by default.
|
||||
/// </summary>
|
||||
public bool ReplaceFeature { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutobahnTestApp
|
||||
|
|
@ -16,11 +17,14 @@ namespace AutobahnTestApp
|
|||
{
|
||||
if (!env.IsEnvironment("NativeSockets"))
|
||||
{
|
||||
app.UseWebSockets(new WebSocketOptions
|
||||
// Register a middleware that disables the server-provided WebSockets feature
|
||||
app.Use((context, next) =>
|
||||
{
|
||||
ReplaceFeature = true
|
||||
context.Features.Set<IHttpWebSocketFeature>(null);
|
||||
return next();
|
||||
});
|
||||
}
|
||||
app.UseWebSockets();
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue