The model defined in
|
case class ServerSentEvent( |
|
data: Option[String] = None, |
|
eventType: Option[String] = None, |
|
id: Option[String] = None, |
|
retry: Option[Int] = None |
|
) { |
|
override def toString: String = { |
|
val _data = data.map(_.split("\n")).map(_.map(line => Some(s"data: $line"))).getOrElse(Array.empty[Option[String]]) |
|
val _event = eventType.map(event => s"event: $event") |
|
val _id = id.map(id => s"id: $id") |
|
val _retry = retry.map(retryCount => s"retry: $retryCount") |
|
(_data :+ _event :+ _id :+ _retry).flatten.mkString("\n") |
|
} |
|
} |
does not match the specification at
https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation
Specifically, this part:
If the line starts with a U+003A COLON character (:)
Therefore there is currently no way to send or receive "comment" messages, which are useful to perform keep-alives.
One could argue that you can just send event: keep-alive here, to which I agree, but just noticed this discrepancy and wondered whether we should add a way to send out these comment messages.
The model defined in
sttp-model/core/src/main/scala/sttp/model/sse/ServerSentEvent.scala
Lines 5 to 18 in afd84a6
Specifically, this part:
Therefore there is currently no way to send or receive "comment" messages, which are useful to perform keep-alives.
One could argue that you can just send
event: keep-alivehere, to which I agree, but just noticed this discrepancy and wondered whether we should add a way to send out these comment messages.