Skip to content

Commit

Permalink
revert HttpHeader and update HeaderParser.failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjiafu committed Jul 10, 2024
1 parent 99cba4d commit b844024
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ private[http] class HeaderParser(
def failure(error: Throwable): HeaderParser.Failure =
HeaderParser.Failure {
error match {
case IllegalUriException(info) => info
case NonFatal(e) => ErrorInfo.fromCompoundString(e.getMessage)
case IllegalUriException(info) => info
case NonFatal(e) if e.getMessage == null => ErrorInfo.fromCompoundString(e.toString)
case NonFatal(e) => ErrorInfo.fromCompoundString(e.getMessage)
}
}
def ruleNotFound(ruleName: String): Result = HeaderParser.RuleNotFound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,10 @@ object HttpHeader {
case HeaderParser.RuleNotFound => ParsingResult.Ok(RawHeader(name, preProcessedValue), Nil)
}
case Failure(error) =>
val info = error match {
case e: ParseError => parser.parseError(e).info
case e if e.getMessage == null => ErrorInfo()
case e => parser.failure(e).info
}
val info = (error match {
case e: ParseError => parser.parseError(e)
case e => parser.failure(e)
}).info
ParsingResult.Error(info.withSummaryPrepended(s"Illegal HTTP header value"))
}
} else ParsingResult.Error(ErrorInfo(s"Illegal HTTP header name", name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,9 @@ class HttpHeaderSpec extends AnyFreeSpec with Matchers {
}

"should not broken when header-value is null" in {
parse("Content-Disposition", null).errors.head.isInstanceOf[ErrorInfo] shouldBe true
val errors = parse("Content-Disposition", null).errors
errors.size shouldBe 1
errors.head shouldBe an[ErrorInfo]
}

}
Expand Down

0 comments on commit b844024

Please sign in to comment.