blob: b55d104a4e7aaead605deff0103b92ccdbbf0364 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package com.softwaremill.sttp.streaming
import java.nio.ByteBuffer
import cats.effect._
import cats.implicits._
import com.softwaremill.sttp.asynchttpclient.fs2.AsyncHttpClientFs2Handler
import com.softwaremill.sttp.{ForceWrappedValue, SttpHandler}
import fs2._
class AsyncHttpClientFs2StreamingTests
extends TestStreamingHandler[IO, Stream[IO, ByteBuffer]] {
override implicit val handler: SttpHandler[IO, Stream[IO, ByteBuffer]] =
AsyncHttpClientFs2Handler[IO]()
override implicit val forceResponse: ForceWrappedValue[IO] =
ForceWrappedValue.catsIo
override def bodyProducer(body: String): Stream[IO, ByteBuffer] =
Stream.emits(body.getBytes("utf-8").map(b => ByteBuffer.wrap(Array(b))))
override def bodyConsumer(stream: Stream[IO, ByteBuffer]): IO[String] =
stream
.map(bb => Chunk.array(bb.array))
.through(text.utf8DecodeC)
.runFoldMonoid
}
|