File tree 3 files changed +10
-26
lines changed
src/Components/Server/src
3 files changed +10
-26
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,9 @@ namespace Microsoft.AspNetCore.Components.Server;
11
11
/// </summary>
12
12
public class ServerComponentsEndpointOptions
13
13
{
14
- /// <summary>
15
- /// Gets or sets a value that indicates whether compression is enabled for the WebSocket connections.
16
- /// </summary>
17
- public bool EnableWebSocketCompression { get ; set ; } = true ;
18
-
19
14
/// <summary>
20
15
/// Gets or sets the <c>frame-ancestors</c> <c>Content-Security-Policy</c> to set in the
21
- /// <see cref="HttpResponse"/> when <see cref="EnableWebSocketCompression " /> is enabled .
16
+ /// <see cref="HttpResponse"/> when <see cref="ConfigureConnectionOptions " /> is set .
22
17
/// </summary>
23
18
/// <remarks>
24
19
/// <para>Setting this value to <see langword="null" /> will prevent the policy from being
@@ -39,8 +34,11 @@ public class ServerComponentsEndpointOptions
39
34
40
35
/// <summary>
41
36
/// Gets or sets a callback to configure the underlying <see cref="HttpConnectionDispatcherOptions"/>.
42
- /// If set, <see cref="ContentSecurityFrameAncestorPolicy"/> will be applied independent of the value of
43
- /// <see cref="EnableWebSocketCompression "/>.
37
+ /// By default, a policy that enables compression and sets a Content Security Policy for the frame ancestors
38
+ /// defined in <see cref="ContentSecurityFrameAncestorPolicy "/> will be applied .
44
39
/// </summary>
45
- public Action < HttpConnectionDispatcherOptions > ConfigureConnectionOptions { get ; set ; }
40
+ public Action < HttpConnectionDispatcherOptions > ConfigureConnectionOptions { get ; set ; } = EnableCompressionDefaults ;
41
+
42
+ private static WebSocketAcceptContext EnableCompressionDefaults ( HttpContext context ) =>
43
+ new ( ) { DangerousEnableCompression = true } ;
46
44
}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public static RazorComponentsEndpointConventionBuilder AddInteractiveServerRende
38
38
39
39
ComponentEndpointConventionBuilderHelper . AddRenderMode ( builder , new InternalServerRenderMode ( options ) ) ;
40
40
41
- if ( ( options . EnableWebSocketCompression || options . ConfigureConnectionOptions is not null ) && options . ContentSecurityFrameAncestorPolicy != null )
41
+ if ( options . ConfigureConnectionOptions is not null && options . ContentSecurityFrameAncestorPolicy != null )
42
42
{
43
43
builder . AddEndpointFilter ( new RequireCspFilter ( options . ContentSecurityFrameAncestorPolicy ) ) ;
44
44
}
Original file line number Diff line number Diff line change @@ -65,20 +65,9 @@ public override IEnumerable<RouteEndpointBuilder> GetEndpointBuilders(
65
65
}
66
66
67
67
var endpointRouteBuilder = new EndpointRouteBuilder ( Services , applicationBuilder ) ;
68
- if ( renderMode is InternalServerRenderMode { Options : var configureOptions } &&
69
- configureOptions != null )
68
+ if ( renderMode is InternalServerRenderMode { Options . ConfigureConnectionOptions : { } configureConnection } )
70
69
{
71
- if ( configureOptions . ConfigureConnectionOptions != null )
72
- {
73
- endpointRouteBuilder . MapBlazorHub ( "/_blazor" , configureOptions . ConfigureConnectionOptions ) ;
74
- }
75
- else if ( configureOptions . EnableWebSocketCompression )
76
- {
77
- endpointRouteBuilder . MapBlazorHub ( "/_blazor" , options =>
78
- {
79
- options . WebSockets . WebSocketAcceptContextFactory = EnableCompressionDefaults ;
80
- } ) ;
81
- }
70
+ endpointRouteBuilder . MapBlazorHub ( "/_blazor" , configureOptions . ConfigureConnectionOptions ) ;
82
71
}
83
72
else
84
73
{
@@ -88,9 +77,6 @@ public override IEnumerable<RouteEndpointBuilder> GetEndpointBuilders(
88
77
return endpointRouteBuilder . GetEndpoints ( ) ;
89
78
}
90
79
91
- private static WebSocketAcceptContext EnableCompressionDefaults ( HttpContext context ) =>
92
- new ( ) { DangerousEnableCompression = true } ;
93
-
94
80
public override bool Supports ( IComponentRenderMode renderMode )
95
81
{
96
82
return renderMode switch
You can’t perform that action at this time.
0 commit comments