Skip to content

Commit d817523

Browse files
committed
Feedback
1 parent 25de6cc commit d817523

File tree

10 files changed

+61
-34
lines changed

10 files changed

+61
-34
lines changed

src/Servers/Connections.Abstractions/ref/Microsoft.AspNetCore.Connections.Abstractions.netcoreapp.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public partial interface IMultiplexedConnectionFactory
142142
public partial interface IMultiplexedConnectionListener : System.IAsyncDisposable
143143
{
144144
System.Net.EndPoint EndPoint { get; }
145-
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext> AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
145+
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext> AcceptAsync(Microsoft.AspNetCore.Http.Features.IFeatureCollection features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
146146
System.Threading.Tasks.ValueTask UnbindAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
147147
}
148148
public partial interface IMultiplexedConnectionListenerFactory
@@ -156,11 +156,6 @@ public MultiplexedConnectionBuilder(System.IServiceProvider applicationServices)
156156
public Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate Build() { throw null; }
157157
public Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder Use(System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate, Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate> middleware) { throw null; }
158158
}
159-
public static partial class MultiplexedConnectionBuilderExtensions
160-
{
161-
public static Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder Run(this Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder connectionBuilder, System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext, System.Threading.Tasks.Task> middleware) { throw null; }
162-
public static Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder UseMultiplexed(this Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder connectionBuilder, System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext, System.Func<System.Threading.Tasks.Task>, System.Threading.Tasks.Task> middleware) { throw null; }
163-
}
164159
public abstract partial class MultiplexedConnectionContext : Microsoft.AspNetCore.Connections.BaseConnectionContext, System.IAsyncDisposable
165160
{
166161
protected MultiplexedConnectionContext() { }
@@ -171,7 +166,7 @@ protected MultiplexedConnectionContext() { }
171166
public abstract partial class StreamContext : Microsoft.AspNetCore.Connections.ConnectionContext
172167
{
173168
protected StreamContext() { }
174-
public abstract long StreamId { get; }
169+
public abstract string StreamId { get; }
175170
}
176171
[System.FlagsAttribute]
177172
public enum TransferFormat
@@ -244,6 +239,10 @@ public partial interface IStreamDirectionFeature
244239
bool CanRead { get; }
245240
bool CanWrite { get; }
246241
}
242+
public partial interface IStreamIdFeature
243+
{
244+
long StreamId { get; }
245+
}
247246
public partial interface ITlsHandshakeFeature
248247
{
249248
System.Security.Authentication.CipherAlgorithmType CipherAlgorithm { get; }

src/Servers/Connections.Abstractions/ref/Microsoft.AspNetCore.Connections.Abstractions.netstandard2.0.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public partial interface IMultiplexedConnectionFactory
142142
public partial interface IMultiplexedConnectionListener : System.IAsyncDisposable
143143
{
144144
System.Net.EndPoint EndPoint { get; }
145-
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext> AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
145+
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext> AcceptAsync(Microsoft.AspNetCore.Http.Features.IFeatureCollection features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
146146
System.Threading.Tasks.ValueTask UnbindAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
147147
}
148148
public partial interface IMultiplexedConnectionListenerFactory
@@ -156,11 +156,6 @@ public MultiplexedConnectionBuilder(System.IServiceProvider applicationServices)
156156
public Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate Build() { throw null; }
157157
public Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder Use(System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate, Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate> middleware) { throw null; }
158158
}
159-
public static partial class MultiplexedConnectionBuilderExtensions
160-
{
161-
public static Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder Run(this Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder connectionBuilder, System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext, System.Threading.Tasks.Task> middleware) { throw null; }
162-
public static Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder UseMultiplexed(this Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder connectionBuilder, System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext, System.Func<System.Threading.Tasks.Task>, System.Threading.Tasks.Task> middleware) { throw null; }
163-
}
164159
public abstract partial class MultiplexedConnectionContext : Microsoft.AspNetCore.Connections.BaseConnectionContext, System.IAsyncDisposable
165160
{
166161
protected MultiplexedConnectionContext() { }
@@ -171,7 +166,7 @@ protected MultiplexedConnectionContext() { }
171166
public abstract partial class StreamContext : Microsoft.AspNetCore.Connections.ConnectionContext
172167
{
173168
protected StreamContext() { }
174-
public abstract long StreamId { get; }
169+
public abstract string StreamId { get; }
175170
}
176171
[System.FlagsAttribute]
177172
public enum TransferFormat
@@ -244,6 +239,10 @@ public partial interface IStreamDirectionFeature
244239
bool CanRead { get; }
245240
bool CanWrite { get; }
246241
}
242+
public partial interface IStreamIdFeature
243+
{
244+
long StreamId { get; }
245+
}
247246
public partial interface ITlsHandshakeFeature
248247
{
249248
System.Security.Authentication.CipherAlgorithmType CipherAlgorithm { get; }

src/Servers/Connections.Abstractions/ref/Microsoft.AspNetCore.Connections.Abstractions.netstandard2.1.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public partial interface IMultiplexedConnectionFactory
142142
public partial interface IMultiplexedConnectionListener : System.IAsyncDisposable
143143
{
144144
System.Net.EndPoint EndPoint { get; }
145-
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext> AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
145+
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext> AcceptAsync(Microsoft.AspNetCore.Http.Features.IFeatureCollection features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
146146
System.Threading.Tasks.ValueTask UnbindAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
147147
}
148148
public partial interface IMultiplexedConnectionListenerFactory
@@ -156,11 +156,6 @@ public MultiplexedConnectionBuilder(System.IServiceProvider applicationServices)
156156
public Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate Build() { throw null; }
157157
public Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder Use(System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate, Microsoft.AspNetCore.Connections.MultiplexedConnectionDelegate> middleware) { throw null; }
158158
}
159-
public static partial class MultiplexedConnectionBuilderExtensions
160-
{
161-
public static Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder Run(this Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder connectionBuilder, System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext, System.Threading.Tasks.Task> middleware) { throw null; }
162-
public static Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder UseMultiplexed(this Microsoft.AspNetCore.Connections.IMultiplexedConnectionBuilder connectionBuilder, System.Func<Microsoft.AspNetCore.Connections.MultiplexedConnectionContext, System.Func<System.Threading.Tasks.Task>, System.Threading.Tasks.Task> middleware) { throw null; }
163-
}
164159
public abstract partial class MultiplexedConnectionContext : Microsoft.AspNetCore.Connections.BaseConnectionContext, System.IAsyncDisposable
165160
{
166161
protected MultiplexedConnectionContext() { }
@@ -171,7 +166,7 @@ protected MultiplexedConnectionContext() { }
171166
public abstract partial class StreamContext : Microsoft.AspNetCore.Connections.ConnectionContext
172167
{
173168
protected StreamContext() { }
174-
public abstract long StreamId { get; }
169+
public abstract string StreamId { get; }
175170
}
176171
[System.FlagsAttribute]
177172
public enum TransferFormat
@@ -244,6 +239,10 @@ public partial interface IStreamDirectionFeature
244239
bool CanRead { get; }
245240
bool CanWrite { get; }
246241
}
242+
public partial interface IStreamIdFeature
243+
{
244+
long StreamId { get; }
245+
}
247246
public partial interface ITlsHandshakeFeature
248247
{
249248
System.Security.Authentication.CipherAlgorithmType CipherAlgorithm { get; }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
namespace Microsoft.AspNetCore.Connections.Features
5+
{
6+
public interface IStreamIdFeature
7+
{
8+
long StreamId { get; }
9+
}
10+
}

src/Servers/Connections.Abstractions/src/IMulitplexedConnectionListener.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Net;
66
using System.Threading;
77
using System.Threading.Tasks;
8+
using Microsoft.AspNetCore.Http.Features;
89

910
namespace Microsoft.AspNetCore.Connections
1011
{
@@ -28,8 +29,9 @@ public interface IMultiplexedConnectionListener : IAsyncDisposable
2829
/// <summary>
2930
/// Begins an asynchronous operation to accept an incoming connection.
3031
/// </summary>
32+
/// <param name="features">A feature collection to pass options when accepting a connection.</param>
3133
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
3234
/// <returns>A <see cref="ValueTask{ConnectionContext}"/> that completes when a connection is accepted, yielding the <see cref="MultiplexedConnectionContext" /> representing the connection.</returns>
33-
ValueTask<MultiplexedConnectionContext> AcceptAsync(CancellationToken cancellationToken = default);
35+
ValueTask<MultiplexedConnectionContext> AcceptAsync(IFeatureCollection features = null, CancellationToken cancellationToken = default);
3436
}
3537
}

src/Servers/Connections.Abstractions/src/StreamContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ public abstract class StreamContext : ConnectionContext
88
/// <summary>
99
/// Gets the id assigned to the stream.
1010
/// </summary>
11-
public abstract long StreamId { get; }
11+
public abstract string StreamId { get; }
1212
}
1313
}

src/Servers/Kestrel/Core/src/Internal/Http3/Http3Connection.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ internal async Task InnerProcessRequestsAsync<TContext>(IHttpApplication<TContex
205205
break;
206206
}
207207

208-
var streamDirectionFeature = streamContext.Features.Get<IStreamDirectionFeature>();
208+
var quicStreamFeature = streamContext.Features.Get<IStreamDirectionFeature>();
209+
var streamIdFeature = streamContext.Features.Get<IStreamIdFeature>();
209210

210-
Debug.Assert(streamDirectionFeature != null);
211+
Debug.Assert(quicStreamFeature != null);
211212

212213
var httpConnectionContext = new Http3StreamContext
213214
{
214-
ConnectionId = streamContext.StreamId.ToString(),
215+
ConnectionId = streamContext.StreamId,
215216
StreamContext = streamContext,
216217
// TODO connection context is null here. Should we set it to anything?
217218
ServiceContext = _context.ServiceContext,
@@ -223,7 +224,7 @@ internal async Task InnerProcessRequestsAsync<TContext>(IHttpApplication<TContex
223224
RemoteEndPoint = streamContext.RemoteEndPoint as IPEndPoint
224225
};
225226

226-
if (!streamDirectionFeature.CanWrite)
227+
if (!quicStreamFeature.CanWrite)
227228
{
228229
// Unidirectional stream
229230
var stream = new Http3ControlStream<TContext>(application, this, httpConnectionContext);
@@ -232,7 +233,7 @@ internal async Task InnerProcessRequestsAsync<TContext>(IHttpApplication<TContex
232233
else
233234
{
234235
// Keep track of highest stream id seen for GOAWAY
235-
var streamId = streamContext.StreamId;
236+
var streamId = streamIdFeature.StreamId;
236237
HighestStreamId = streamId;
237238

238239
var http3Stream = new Http3Stream<TContext>(application, this, httpConnectionContext);

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicConnectionListener.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Threading;
1010
using System.Threading.Tasks;
1111
using Microsoft.AspNetCore.Connections;
12+
using Microsoft.AspNetCore.Http.Features;
1213

1314
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Internal
1415
{
@@ -36,7 +37,7 @@ public QuicConnectionListener(QuicTransportOptions options, IQuicTrace log, EndP
3637

3738
public EndPoint EndPoint { get; set; }
3839

39-
public async ValueTask<MultiplexedConnectionContext> AcceptAsync(CancellationToken cancellationToken = default)
40+
public async ValueTask<MultiplexedConnectionContext> AcceptAsync(IFeatureCollection features = null, CancellationToken cancellationToken = default)
4041
{
4142
var quicConnection = await _listener.AcceptConnectionAsync(cancellationToken);
4243
try

src/Servers/Kestrel/Transport.Quic/src/Internal/QuicStreamContext.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Internal
1616
{
17-
internal class QuicStreamContext : TransportStream, IStreamDirectionFeature, IProtocolErrorCodeFeature
17+
internal class QuicStreamContext : TransportStream, IStreamDirectionFeature, IProtocolErrorCodeFeature, IStreamIdFeature
1818
{
1919
private readonly Task _processingTask;
2020
private readonly QuicStream _stream;
@@ -67,14 +67,22 @@ public QuicStreamContext(QuicStream stream, QuicConnectionContext connection, Qu
6767
public bool CanRead { get; }
6868
public bool CanWrite { get; }
6969

70-
public override long StreamId
70+
long IStreamIdFeature.StreamId
7171
{
7272
get
7373
{
7474
return _stream.StreamId;
7575
}
7676
}
7777

78+
public override string StreamId
79+
{
80+
get
81+
{
82+
return _stream.StreamId.ToString();
83+
}
84+
}
85+
7886
public override string ConnectionId
7987
{
8088
get

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3TestBase.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,18 +479,20 @@ public override ValueTask<StreamContext> ConnectAsync(IFeatureCollection feature
479479
}
480480
}
481481

482-
private class TestStreamContext : StreamContext
482+
private class TestStreamContext : StreamContext, IStreamDirectionFeature, IStreamIdFeature
483483
{
484484
private DuplexPipePair _pair;
485485
public TestStreamContext(bool canRead, bool canWrite, DuplexPipePair pair, IProtocolErrorCodeFeature feature)
486486
{
487487
_pair = pair;
488488
Features = new FeatureCollection();
489-
Features.Set<IStreamDirectionFeature>(new DefaultStreamDirectionFeature(canRead, canWrite));
489+
Features.Set<IStreamDirectionFeature>(this);
490+
CanRead = canRead;
491+
CanWrite = canWrite;
490492
Features.Set<IProtocolErrorCodeFeature>(feature);
491493
}
492494

493-
public override long StreamId { get; }
495+
public override string StreamId { get; }
494496

495497
public override string ConnectionId { get; set; }
496498

@@ -510,6 +512,12 @@ public override IDuplexPipe Transport
510512
}
511513
}
512514

515+
public bool CanRead { get; }
516+
517+
public bool CanWrite { get; }
518+
519+
long IStreamIdFeature.StreamId { get; }
520+
513521
public override void Abort(ConnectionAbortedException abortReason)
514522
{
515523
_pair.Application.Output.Complete(abortReason);

0 commit comments

Comments
 (0)