Skip to content

Commit

Permalink
Merge pull request #189 from http4s/update/http4s-1.0.0-M36
Browse files Browse the repository at this point in the history
Update to http4s 1.0.0-M36
  • Loading branch information
armanbilge authored Aug 26, 2022
2 parents acd6704 + db6369f commit 28f41cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions dom/src/main/scala/org/http4s/dom/FetchClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions dom/src/main/scala/org/http4s/dom/ServiceWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 28f41cb

Please sign in to comment.