-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add AllowLineTerminator option in KestrelServerOptions #43252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
Relevant PR: #41101 Does the spec take a position on whether servers ought to be tolerant of this or not? I know that at least some customers need this, but is this common? I don't want to make If we do need public API, I think it needs to be clear what we're enabling the line feed terminator for. This also applies to the name of the switch. _enableLineFeedTerminator = AppContext.TryGetSwitch("Microsoft.AspNetCore.Server.Kestrel.EnableLineFeedTerminator", out var enabled) && enabled; I think |
Correct PR: #43202 |
I see. I linked to the .NET 6 backport PR where we cannot change public API. Can we just continue using the AppContext switch in |
Using an option in 7 was a decision we made at the time of the issue, because we wanted it to be an officially supported feature.
But let's see if what everyone things about it.
|
I remember wanting it shipped in an official release, but I didn't know that "officially supported" meant a public API rather than an AppContext switch. I feel that we can officially support a feature either way by promising not to remove it. We could remove a public API as well, although there is more process around obsoleting those. |
Yea, this is a case RFC 7230 acknowledges.
(https://www.rfc-editor.org/rfc/rfc7230#section-3.5) Regarding the question of whether this should be public API or AppContext switch, I think it comes down to defining what each of those things should be used for. This is an opt-in feature that's new and we intend to keep it, so IMO it makes sense that it would be public API surface. I think the original intent of the AppContext switches was to allow people to use them for compat reasons (i.e. opt out of new behavior), though I realize they've now been used for other purposes as well. |
I can buy this should be an option. What do we think about Also, if there are going to be other HTTP parsing knobs, do we need to want to add a subclass to |
Also, would we ever consider making this opt-out? Then we could avoid adding yet another option and the AppContext switch would serve its intended purpose of opting out of new behavior. Allowing linefeeds doesn't really regress perf now, does it? |
I don't have a strong opinion between the two. If you feel that adding the
You mean both the AppContext switch and the property? That seems unnecessary, no? IMO the number of people who will actually opt into the switch on 6.0 and then upgrade to 7+ will be small. Most (of the small number of) people who use this will start with 7+ so I'm not too worried about not supporting the switch anymore.
Ooh, good question. I feel the same. I don't think we have any other parsing options planned at the moment, but I wouldn't bet against running into another case we want to add in .NET 8. It's clunky to have a single thing in |
I think we should have properties for http1 2 and 3 like we have limits. |
You know, if you squint hard enough this setting does look kind of like a limit 😆 |
It limits what byte sequences we will accept as a start line and header terminators after all! |
I don't mind a new It's better than adding a clunky |
API review notes:
_enableLineFeedTerminator = AppContext.TryGetSwitch("Microsoft.AspNetCore.Server.Kestrel.DisableHttp1LineFeedTerminators", out var disabled) && disabled; Technically, not new API, but let's use this name. |
We should consider having a separate "DontObeyRFCs" type of options. This isn't as silly as it sounds, it would highlight some things which shouldn't be used unless you really have a need due to weird clients, or being Bing. It'd make them less discoverable by accident too. |
I'd be more okay with a single "strict mode" option for Kestrel HTTP parsing. Or maybe a "quirks mode" option. I don't wan't to add a million parsing knobs though. I still think we should allow line fee it by default considering the RFC says servers may allow this. I think most people want their HTTP server to just work. I think using Kestrel as a way to validate the RFC compliance of HTTP clients is extremely niche and incomplete anyway. |
Background and Motivation
New option to support LF as a request line terminator.
Proposed API
public class KestrelServerOptions { /// <summary> /// Gets or sets a value that controls whether the request lines /// can end with LF only instead of CR/LF. /// </summary> /// <remarks> /// Defaults to false. /// </remarks> + public bool AllowLineFeedTerminator { get; set; } }
Usage Examples
n/a
Alternative Designs
n/a
Risks
The change is non-breaking, the default is not activating the new feature. The feature has been verified in production by Azure App Service.
The text was updated successfully, but these errors were encountered: