After reading the documentation on the spray-http Content-Type Header, I changed my function to:
def correctJsonHeaders(req:spray.http.HttpRequest) = {
if(req.headers.exists(hdr => hdr.name == "Content-Type" && hdr.value == "text/json")){
val tweakedEntity = spray.http.HttpEntity(`application/json`, req.entity.data)
req.copy(entity = tweakedEntity)
}
else req
}
which seems to work. The trick was to change the HttpEntity, instead of the header.