Skip to content

API Proposal: Consider adding a WaitForDataBeforeAllocatingBuffer in HttpsConnectionMiddleware #30877

Closed
@davidfowl

Description

@davidfowl

Background and Motivation

As part of #30863, we're doing zero byte reads as a way to save memory. In some cases it might be better for performance (like in HTTPs based benchmarks), if we don't do a zero byte read before the actual read. Note, this isn't as big a deal as in the transport layer because it's not a real sys call we're making. We're calling into an in memory implementation.

Proposed API

namespace Microsoft.AspNetCore.Server.Kestrel.Https
{
    public class HttpsConnectionAdapterOptions
    {
+       public bool WaitForDataBeforeAllocatingBuffer { get; set; }
    }

Usage Examples

var host = new HostBuilder()
                .ConfigureWebHost(webHostBuilder =>
                {
                    webHostBuilder
                        .UseKestrel(options =>
                        {
                            options.Listen(IPAddress.Loopback, 5001, o => o.UseHttps(https => https.WaitForDataBeforeAllocatingBuffer = true ));
                        })
                        .UseStartup<Startup>();
                })
                .Build();

            await host.RunAsync();

Risks

None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions