Skip to content

Commit

Permalink
Use ValueTask
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Jun 3, 2022
1 parent 4b82712 commit ff7fd2b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Http/Http.Features/src/IHttpConnectFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ public interface IHttpConnectFeature
/// Send the response headers with a 200 status code and transition to opaque streaming.
/// </summary>
/// <returns>An opaque bidirectional stream.</returns>
Task<Stream> AcceptAsync();
ValueTask<Stream> AcceptAsync();
}
4 changes: 2 additions & 2 deletions src/Http/Http.Features/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#nullable enable
Microsoft.AspNetCore.Http.Features.IHttpConnectFeature
Microsoft.AspNetCore.Http.Features.IHttpConnectFeature.AcceptAsync() -> System.Threading.Tasks.Task<System.IO.Stream!>!
Microsoft.AspNetCore.Http.Features.IHttpConnectFeature.AcceptAsync() -> System.Threading.Tasks.ValueTask<System.IO.Stream!>
Microsoft.AspNetCore.Http.Features.IHttpConnectFeature.IsConnectRequest.get -> bool
Microsoft.AspNetCore.Http.Features.IHttpConnectFeature.Protocol.get -> string!
Microsoft.AspNetCore.Http.Features.IHttpConnectFeature.Protocol.get -> string?
1 change: 0 additions & 1 deletion src/Middleware/WebSockets/src/WebSocketMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public sealed class ConnectFeature : IHttpConnectFeature
public Stream Stream { get; set; } = Stream.Null;

/// <inheritdoc/>
public Task<Stream> AcceptAsync()
public ValueTask<Stream> AcceptAsync()
{
if (!IsConnectRequest)
{
throw new InvalidOperationException("This is not a CONNECT request.");
}

return Task.FromResult(Stream);
return new ValueTask<Stream>(Stream);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async Task<Stream> IHttpUpgradeFeature.UpgradeAsync()
return _bodyControl!.Upgrade();
}

async Task<Stream> IHttpConnectFeature.AcceptAsync()
async ValueTask<Stream> IHttpConnectFeature.AcceptAsync()
{
if (!IsConnectRequest)
{
Expand Down

0 comments on commit ff7fd2b

Please sign in to comment.