diff --git a/build.sbt b/build.sbt index 51d40260..be077e7b 100644 --- a/build.sbt +++ b/build.sbt @@ -124,7 +124,7 @@ ThisBuild / Test / jsEnv := { val catsEffectVersion = "3.3.14" val fs2Version = "3.2.12" -val http4sVersion = "1.0.0-M34" +val http4sVersion = "1.0.0-M36" val scalaJSDomVersion = "2.2.0" val circeVersion = "0.14.2" val munitVersion = "0.7.29" diff --git a/dom/src/main/scala/org/http4s/dom/FetchClient.scala b/dom/src/main/scala/org/http4s/dom/FetchClient.scala index 11848da5..43ed2cec 100644 --- a/dom/src/main/scala/org/http4s/dom/FetchClient.scala +++ b/dom/src/main/scala/org/http4s/dom/FetchClient.scala @@ -31,6 +31,7 @@ import org.scalajs.dom.Headers import org.scalajs.dom.HttpMethod import org.scalajs.dom.RequestInit import org.scalajs.dom.{Response => FetchResponse} +import scodec.bits.ByteVector import java.util.concurrent.TimeoutException import scala.concurrent.duration._ @@ -44,8 +45,8 @@ private[dom] object FetchClient { Resource.eval(req.toStrict(None)).flatMap { req => val body = req.entity match { case Entity.Empty => None - case Entity.Strict(chunk) => Some(chunk) - case default => default.body.chunkAll.filter(_.nonEmpty).compile.last + case Entity.Strict(bytes) => Some(bytes) + case default => Some(default.body.compile.to(ByteVector)).filter(_.nonEmpty) } Resource diff --git a/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala b/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala index 17611d46..ff0885ea 100644 --- a/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala +++ b/dom/src/main/scala/org/http4s/dom/ServiceWorker.scala @@ -26,13 +26,13 @@ import cats.effect.kernel.Deferred import cats.effect.std.Supervisor import cats.effect.unsafe.IORuntime import cats.syntax.all._ -import fs2.Chunk import org.scalajs.dom.Fetch import org.scalajs.dom.FetchEvent import org.scalajs.dom.ResponseInit import org.scalajs.dom.ServiceWorkerGlobalScope import org.scalajs.dom.{Response => DomResponse} import org.typelevel.vault.Key +import scodec.bits.ByteVector object ServiceWorker { @@ -78,14 +78,14 @@ object ServiceWorker { uri <- OptionF.fromEither(Uri.fromString(req.url)) headers = fromDomHeaders(req.headers) body <- OptionT.liftF(F.fromPromise(F.delay(req.arrayBuffer()))) - chunk = Chunk.jsArrayBuffer(body) - request = Request[F](method, uri, headers = headers, entity = Entity.Strict(chunk)) + bytes = ByteVector.fromJSArrayBuffer(body) + request = Request[F](method, uri, headers = headers, entity = Entity.Strict(bytes)) .withAttribute(key, FetchEventContext(event, supervisor)) response <- routes(request) body <- OptionT.liftF( response.entity match { case Entity.Empty => None.pure - case Entity.Strict(chunk) => Some(chunk.toUint8Array).pure + case Entity.Strict(bytes) => Some(bytes.toUint8Array).pure case default => default.body.chunkAll.filter(_.nonEmpty).map(_.toUint8Array).compile.last }