From 4e8df0a0ec1411a79e2737a5ec32d1c105fe2ea0 Mon Sep 17 00:00:00 2001 From: Yufan Gong Date: Wed, 30 Oct 2019 18:51:45 +0000 Subject: [PATCH] util-core: Introduce Reader.readAllItems for generic types Problem: Reader.readAll was Buf biased, and it should be in BufReader. Solution: Move `readAll(r: Reader[Buf])` to `BufReader`, while introduce `readAllItems[A](r: Reader[A])` to the `Reader` object. JIRA Issues: CSL-8869 Differential Revision: https://phabricator.twitter.biz/D391346 --- server/src/main/scala/com/twitter/server/view/IndexView.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/scala/com/twitter/server/view/IndexView.scala b/server/src/main/scala/com/twitter/server/view/IndexView.scala index 3c9f6a59..9fee4a79 100644 --- a/server/src/main/scala/com/twitter/server/view/IndexView.scala +++ b/server/src/main/scala/com/twitter/server/view/IndexView.scala @@ -5,7 +5,7 @@ import com.twitter.finagle.http.Method import com.twitter.finagle.http.Method.{Get, Post} import com.twitter.finagle.{Service, SimpleFilter} import com.twitter.finagle.http.{Request, Response} -import com.twitter.io.{Buf, Reader} +import com.twitter.io.{Buf, BufReader, Reader} import com.twitter.server.util.HtmlUtils.escapeHtml import com.twitter.server.util.HttpUtils.{expectsHtml, newResponse} import com.twitter.util.Future @@ -154,7 +154,7 @@ class IndexView(title: String, uri: String, index: () => Seq[IndexView.Entry]) case res => val body = Reader.fromBuf(Buf.Utf8(content)) val reader = render(title, uri, index().sorted, body) - Reader.readAll(reader).flatMap { html => + BufReader.readAll(reader).flatMap { html => newResponse( contentType = "text/html;charset=UTF-8", content = html