Skip to content
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

Updating mimetype accept header parsing to use builtin aspnet parse/methods #516

Merged

Conversation

Banashek
Copy link
Contributor

@Banashek Banashek commented Jul 6, 2022

Fixes 485

This change updates the mustAccept to base it's decisions on the values of parsed MediaTypeHeaderValue values instead of strings.

It utilizes the isSubsetOf method of that class in order to do proper subset matching.

While the parsing is wrapped in an exception handler during the runtime execution, the construction of the function does not wrap the parsing. This is so that it will fail fast on startup (developer supplied values), but tolerate malformed values at runtime (bad user input).

I've added only a couple of tests, but believe it should suffice for this scenario since the code leans on the Net builtins.

Happy to make changes (remove rfc comments, etc) if desired.

Copy link
Contributor

@baronfel baronfel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I like this approach a lot! Build failures are due to package versions being integers instead of semver versions, as I think you've mentioned in another issue

Copy link
Member

@dustinmoris dustinmoris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, many thanks!

@dustinmoris dustinmoris merged commit afe3cf9 into giraffe-fsharp:develop Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants