用于XML的spray set content-type

时间:2016-03-11 12:55:06

标签: xml scala header spray

尝试发送xml内容类型的Mime-header

sender ! HttpResponse(status = 200, entity = responseBody, headers = List(`Content-Type`(`text/xml`)))

我收到错误:

not found: value text/xml

我尝试使用application / xml也无效,application / json正在使用FWIW

是否缺少某些导入?

编辑:尝试添加此

import spray.http.MediaTypes._
sender ! HttpResponse(status = 400, entity = responseBody, headers = List(`Content-Type`(`application/xml`)))

这给出了以下错误:

Explicitly set response header 'Content-Type: application/xml' is 
ignored, the response Content-Type is set via the response's HttpEntity!

1 个答案:

答案 0 :(得分:0)

import spray.http.HttpEntity    
sender ! HttpResponse(status = 200, entity = httpEntity(`application/xml`,responseBody))

相关文件

http://spray.io/documentation/1.2.2/spray-http/#content-type-header