Skip to content

Commit

Permalink
Merge pull request #38 from hughsimpson/case-insensitive-headers
Browse files Browse the repository at this point in the history
Header names are case insensitive by spec, so we should respect that
  • Loading branch information
dpsoft committed Oct 2, 2018
2 parents 35ca5dc + e14ff5a commit f6af37b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package kamon.akka.http.instrumentation

import scala.collection.immutable.TreeMap

import akka.NotUsed
import akka.http.scaladsl.model.headers.RawHeader
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
Expand Down Expand Up @@ -152,7 +154,9 @@ object ServerFlowWrapper {
)

private def extractContext(request: HttpRequest) = Kamon.contextCodec().HttpHeaders.decode(new TextMap {
private val headersKeyValueMap = request.headers.map(h => h.name -> h.value()).toMap
private val headersKeyValueMap =
new TreeMap[String, String]()(Ordering.comparatorToOrdering(String.CASE_INSENSITIVE_ORDER)) ++
request.headers.map(h => h.name -> h.value())
override def values: Iterator[(String, String)] = headersKeyValueMap.iterator
override def get(key: String): Option[String] = headersKeyValueMap.get(key)
override def put(key: String, value: String): Unit = {}
Expand Down

0 comments on commit f6af37b

Please sign in to comment.