使用 Spray 处理大量下载

Processing large downloads with Spray

我想用 Spray 获取一个可能很大的文件并逐步处理它,而不是一次将整个响应实体加载到内存中。 (具体来说,逐行处理 CSV 文件。)请求将发送到任意服务器,因此我不能期望分块响应。这可能吗?

如果您将 spray.can.client.parsing.incoming-auto-chunking-threshold-size 设置为某个有限值,大于该值的实体将分块传送。看这里:https://github.com/spray/spray/blob/master/spray-can/src/main/resources/reference.conf#L372

请参阅此票证以了解 spray 中的分块和流式处理功能的概述:https://github.com/spray/spray/issues/281