Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to http4s 1.0.0-M36 #189

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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