Вопрос

Suppose I am using dispatch to call a REST API in Scala. The API may return very large responses that don't fit the memory I have.

So I would like to read a response from the network in a fixed-size buffer and raise an exception (return an error) if the response size > the buffer size.

How can I do it with the dispatch library ?

Это было полезно?

Решение

Use one of the stream conversion operators, such as >>, to get an input stream and check the content of the stream for length, etc.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top