On 07/16/2011 02:56 AM, parsa [via Databinder] wrote:
> I'm willing to use Dispatch in a sandboxed environment, where among
> all limitations, I need to set a limit on how large the response
> string can be. How can this be achieved in Dispatch? Thanks in advance.
Sure, you can consume the stream/reader/scala.io.Source to build up a
stream of whatever maximum size you want. The String methods are just
doing this:
request >~ { so => so.mkString }
Where so is a scala.io.Source. Source works line by line so if you are
concerned about very long lines you may want to work with lower level
java stream or reader. For reader,
request >>~ { reader => [make as big of a string as you want here] }
and that value will be returned. Sources here:
https://github.com/n8han/Databinder-Dispatch/blob/master/core/src/main/scala/handlers.scala#L88Nathan