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
Replace Accept-Ranges
parser with cats-parse implementation
#3995
Replace Accept-Ranges
parser with cats-parse implementation
#3995
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This is a great start. Replace the repSep, but I think you're on the right track here.
|
||
/* https://tools.ietf.org/html/rfc7233#appendix-C */ | ||
val parser: P[`Accept-Ranges`] = { | ||
val ListSep: P[Unit] = Rfc7230.ows *> P.char(',') *> Rfc7230.ows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will do a fine job on the ows-comma-ows that reasonable actors will send, but not the empty elements between commas (including leading and trailing commas) that the spec mandates. Rfc7230.headerRep1
should take care of those.
val parser: P[`Accept-Ranges`] = { | ||
val ListSep: P[Unit] = Rfc7230.ows *> P.char(',') *> Rfc7230.ows | ||
|
||
val none = P.string1("none").as(Nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of as
.
) | ||
) | ||
|
||
acceptableRanges.map(headers.`Accept-Ranges`.apply) /* is EOL necessary? */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is correct. Calling parseAll
means Accept-Ranges.parse
will have to consume the entire input, and if this is composed into other parsers, we want it to leave the leftovers.
Last commit should implement requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a slight tweak to the error message, but this look great. Thanks!
This is a preliminary PR to request feedback, it does not fully replace
RangeParser
yet.I added the cats-parse implementation to the
Accept-Ranges
companion object and I'd like some general feedback on my usage of cats-parse and any formatting/style stuff.I also have a question about the previous implementation, (here) the top level rule for
Accept-Ranges
is matching on EOL but this caused the cats-parse version to fail tests, I assume that parboiled2 is different from cats-effect and this is not necessary but I want to confirm this.