Skip to content

Commit

Permalink
fixed empty header parsing (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
mliarakos committed Mar 29, 2020
1 parent d565008 commit ddbd3a0
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,15 @@ private[lagom] abstract class ClientServiceCallInvoker[Request, Response](
}

private object ClientServiceCallInvoker {
private val header = "(.*?):(.*)".r

def parseHeaders(xhr: XMLHttpRequest): Map[String, Seq[String]] = {
xhr
.getAllResponseHeaders()
.split("""\r\n""")
.map(header => {
val Array(key, values) = header.trim.split(":", 2)
key -> values.trim.split(",").map(_.trim).toSeq
.split("\r\n")
.flatMap({
case header(key, values) => Some(key.trim -> values.split(",").map(_.trim).toSeq)
case _ => None
})
.toMap
}
Expand Down

0 comments on commit ddbd3a0

Please sign in to comment.