我需要设置Content-Type = "application/vxml"
,
尝试了以下代码,但无效。
val contentTypeHeader = RawHeader("Content-Type", "application/vxml")
val cacheControlHeader = RawHeader("Cache-Control", "public, max-age=3600")
val acceptRangesHeader = RawHeader("Accept-Ranges", "bytes")
val vxmlResponseHeaders = Seq(contentTypeHeader, cacheControlHeader, acceptRangesHeader)
complete {
actorResponseFuture map { response =>
HttpResponse(StatusCodes.OK,
headers = vxmlResponseHeaders,
entity = HttpEntity(handleResponse(response, uri.toString())))
}
}
但是它会引发以下错误,
2020-04-24 14:24:00.722 WARN [ccc-vxml-activities-akka.actor.default-dispatcher-14] akka.actor.ActorSystemImpl - Explicitly set HTTP header 'Content-Type: application/vxml' is ignored, illegal RawHeader
我以前使用以下代码将Content-Type
设置为text/xml(UTF-8)
,但是由于application/vxml
中没有ContentTypes
,所以我不能使用这种方法。
complete {
actorResponseFuture map { response =>
HttpResponse(StatusCodes.OK,
entity = HttpEntity(ContentTypes.`text/xml(UTF-8)`,
handleResponse(response, uri.toString())))
}
}
任何指针都会有所帮助。