@@ -22,7 +22,7 @@ object RestServlet {
2222 final val DefaultHandleTimeout = 30 .seconds
2323 final val DefaultMaxPayloadSize = 16 * 1024 * 1024L // 16MB
2424 final val CookieHeader = " Cookie"
25- final val DefaultStreamingBatchSize = 1
25+ final val DefaultStreamingBatchSize = 100
2626 private final val BufferSize = 8192
2727
2828 /**
@@ -32,7 +32,7 @@ object RestServlet {
3232 * @param handleTimeout maximum time the servlet will wait for results returned by REST API implementation
3333 * @param maxPayloadSize maximum acceptable incoming payload size, in bytes;
3434 * if exceeded, `413 Payload Too Large` response will be sent back
35- * @param defaultStreamingBatchSize default batch size for [[StreamedRestResponse ]]
35+ * @param defaultStreamingBatchSize default batch when streaming [[StreamedBody.JsonList ]]
3636 */
3737 @ explicitGenerics def apply [RestApi : RawRest .AsRawRpc : RestMetadata ](
3838 apiImpl : RestApi ,
@@ -130,15 +130,14 @@ class RestServlet(
130130 case binary : StreamedBody .RawBinary =>
131131 response.setContentType(binary.contentType)
132132 binary.content
133- .bufferTumbling(stream.customBatchSize.getOrElse(defaultStreamingBatchSize))
134- .consumeWith(Consumer .foreach { batch =>
135- batch.foreach(e => response.getOutputStream.write(e))
133+ .consumeWith(Consumer .foreach { chunk =>
134+ response.getOutputStream.write(chunk)
136135 response.getOutputStream.flush()
137136 })
138137 case jsonList : StreamedBody .JsonList =>
139138 response.setContentType(jsonList.contentType)
140139 jsonList.elements
141- .bufferTumbling(stream .customBatchSize.getOrElse(defaultStreamingBatchSize))
140+ .bufferTumbling(jsonList .customBatchSize.getOrElse(defaultStreamingBatchSize))
142141 .switchIfEmpty(Observable (Seq .empty))
143142 .zipWithIndex
144143 .consumeWith(Consumer .foreach { case (batch, idx) =>
0 commit comments