我想要 result.entity.asString 的内容,但结果是空的。而且我有很多警告让不停。我的代码是:`
implicit val system: ActorSystem = ActorSystem("simple-spray-client")
val log: LoggingAdapter = Logging(system, getClass)
val pipeline: SendReceive = sendReceive
val responseFuture: Future[HttpResponse] = pipeline {
Get("https://api.guildwars2.com/v2/items")
}
val re = responseFuture.onComplete {
case Success(result: HttpResponse) => {
result.entity.asString
shutdown()
}
case Failure(error) =>
log.error(error, "Couldn't get list of items")
shutdown()
}
def shutdown(): Unit = {
IO(Http).ask(Http.CloseAll)(1.second).await
system.shutdown()
}}
` 结果是:
()
[WARN] [10/27/2015 11:26:04.776] [simple-spray-client-akka.actor.default-dispatcher-4] [akka://simple-spray-client/user/IO-HTTP/group-0/0] Illegal response header: Illegal 'Cache-Control' header: Invalid input '"', expected $timesCache$minusControl (line 1, pos 1):
"public, max-age=300"
^
[WARN] [10/27/2015 11:26:04.779] [simple-spray-client-akka.actor.default- dispatcher-4] [akka://simple-spray-client/user/IO-HTTP/group-0/0] Illegal response header: Illegal 'Access-Control-Expose-Headers' header: Invalid input '"', expected $timesAccess$minusControl$minusExpose$minusHeaders (line 1, pos 1):
"X-Result-Total, X-Result-Count"
^