There is a difference between req.response().headers().put(...) and req.response().putHeader(...): The former adds values and the latter overrides everything.
For example, I want to add multiple cookies into a request.
This implementation works as intended:
def addSomeCookie(req: HttpServerRequest, key: String, value: String) =
req.response().headers().put("Set-Cookie", collection.mutable.Set(s"${urlEncode(key)}=${urlEncode(value)}"))
While this implementation overwrites all previous cookies:
def addSomeCookie(req: HttpServerRequest, key: String, value: String) =
req.response().putHeader("Set-Cookie", s"${urlEncode(key)}=${urlEncode(value)}")
It would be a lot better if these two methods had either different names or would behave the same way.