diff --git a/core/src/main/scala/sttp/model/sse/ServerSentEvent.scala b/core/src/main/scala/sttp/model/sse/ServerSentEvent.scala index 9c4ba2af..34020d44 100644 --- a/core/src/main/scala/sttp/model/sse/ServerSentEvent.scala +++ b/core/src/main/scala/sttp/model/sse/ServerSentEvent.scala @@ -3,11 +3,11 @@ package sttp.model.sse import scala.util.Try case class ServerSentEvent( - data: Option[String] = None, - eventType: Option[String] = None, - id: Option[String] = None, - retry: Option[Int] = None -) + data: Option[String] = None, + eventType: Option[String] = None, + id: Option[String] = None, + retry: Option[Int] = None + ) object ServerSentEvent { // https://html.spec.whatwg.org/multipage/server-sent-events.html @@ -25,7 +25,7 @@ object ServerSentEvent { } def composeSSE(sse: ServerSentEvent): String = { - val data = sse.data.map(_.split("\n")).map(_.map(line => Some(s"data: $line"))).getOrElse(Array.empty) + val data = sse.data.map(_.split("\n")).map(_.map(line => Some(s"data: $line"))).getOrElse(Array.empty[Option[String]]) val event = sse.eventType.map(event => s"event: $event") val id = sse.id.map(id => s"id: $id") val retry = sse.retry.map(retryCount => s"retry: $retryCount") @@ -34,8 +34,8 @@ object ServerSentEvent { private def combineData(event: ServerSentEvent, newData: String): ServerSentEvent = { event match { - case e @ ServerSentEvent(Some(oldData), _, _, _) => e.copy(data = Some(s"$oldData\n$newData")) - case e @ ServerSentEvent(None, _, _, _) => e.copy(data = Some(newData)) + case e@ServerSentEvent(Some(oldData), _, _, _) => e.copy(data = Some(s"$oldData\n$newData")) + case e@ServerSentEvent(None, _, _, _) => e.copy(data = Some(newData)) } }