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
migrate multiple simple header parser #4154
Conversation
hmm seems the tests failed, I'll take a look |
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!
ParseResult.fromParser(parser, "Invalid Connection header")(s) | ||
|
||
private[http4s] val parser = | ||
Parser.rep1Sep(Rfc2616.token, 1, Rfc2616BasicRules.listSep).map { (xs: NonEmptyList[String]) => |
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 should be the headerRep1 helper.
@@ -213,4 +214,11 @@ private[http4s] object AdditionalRules { | |||
def EOI = P.char('\uFFFF') | |||
|
|||
def EOL = optWs *> EOI.rep | |||
|
|||
val Digits: Parser1[Long] = P.rep1(Rfc3986.digit, 1).string.mapFilter { s => |
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.
There's a digit
in cats.parse.Rfc5234
that we can use. I guess the value in having a separate rule is that yours does the work of parsing a run of them to a long, while the cats-parse one just gives you the Char.
I think I'd call this Long
, to show that arbitrary lengths will fail. Or maybe even NonNegativeLong
, because a leading minus won't work here. I do think it's useful.
|
||
private[http4s] val parser: Parser[`Strict-Transport-Security`] = { | ||
val maxAge: Parser1[`Strict-Transport-Security`] = | ||
(Parser.string1("max-age=") *> AdditionalRules.Digits).map { (age: Long) => |
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.
Is this case sensitive? I bet it's not, but I'd have to find the RFC.
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.
https://tools.ietf.org/html/rfc6797#section-6.1
Directive names are case-insensitive.
thanks you are right, will change
migrates
Age
Connection
Content-Length
Strict-Transport-Security