Skip to content

Commit

Permalink
Update http4s-ce2 to 0.22.0-RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Jul 13, 2021
1 parent 9c27d6f commit dd14819
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ val jeagerClientVersion = "1.6.0"
val braveOpentracingVersion = "1.0.0"
val zipkinSenderOkHttpVersion = "2.16.3"
val resilience4jVersion = "1.7.1"
val http4s_ce2_version = "0.21.24"
val http4s_ce2_version = "0.22.0-RC1"
val http4s_ce3_version = "0.23.0-RC1"

val compileAndTest = "compile->compile;test->test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sttp.client3.http4s

import java.io.{InputStream, UnsupportedEncodingException}
import java.nio.charset.Charset

import cats.data.NonEmptyList
import cats.effect.concurrent.MVar
import cats.effect.{Blocker, Concurrent, ConcurrentEffect, ContextShift, Resource}
Expand All @@ -12,7 +11,8 @@ import fs2.{Chunk, Stream}
import org.http4s.{ContentCoding, EntityBody, Request => Http4sRequest}
import org.http4s
import org.http4s.client.Client
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import org.typelevel.ci.CIString
import sttp.capabilities.fs2.Fs2Streams
import sttp.client3.http4s.Http4sBackend.EncodingHandler
import sttp.client3.impl.cats.CatsMonadAsyncError
Expand All @@ -38,7 +38,8 @@ class Http4sBackend[F[_]: ConcurrentEffect: ContextShift](
val request = Http4sRequest(
method = methodToHttp4s(r.method),
uri = http4s.Uri.unsafeFromString(r.uri.toString),
headers = http4s.Headers(r.headers.map(h => http4s.Header(h.name, h.value)).toList) ++ extraHeaders,
headers =
http4s.Headers(r.headers.map(h => http4s.Header.Raw(CIString(h.name), h.value)).toList) ++ extraHeaders,
body = entity.body
)

Expand All @@ -49,7 +50,7 @@ class Http4sBackend[F[_]: ConcurrentEffect: ContextShift](
.run(customizeRequest(request))
.use { response =>
val code = StatusCode.unsafeApply(response.status.code)
val headers = response.headers.toList.map(h => Header(h.name.value, h.value))
val headers = response.headers.headers.map(h => Header(h.name.toString, h.value))
val statusText = response.status.reason
val responseMetadata = ResponseMetadata(code, statusText, headers)

Expand Down Expand Up @@ -139,8 +140,9 @@ class Http4sBackend[F[_]: ConcurrentEffect: ContextShift](
}

private def multipartToHttp4s(mp: Part[RequestBody[_]]): http4s.multipart.Part[F] = {
val contentDisposition = http4s.Header(HeaderNames.ContentDisposition, mp.contentDispositionHeaderValue)
val otherHeaders = mp.headers.map(h => http4s.Header(h.name, h.value))
val contentDisposition =
http4s.Header.Raw(CIString(HeaderNames.ContentDisposition), mp.contentDispositionHeaderValue)
val otherHeaders = mp.headers.map(h => http4s.Header.Raw(CIString(h.name), h.value))
val allHeaders = List(contentDisposition) ++ otherHeaders

val body: EntityBody[F] = mp.body match {
Expand All @@ -163,7 +165,7 @@ class Http4sBackend[F[_]: ConcurrentEffect: ContextShift](

private def decompressResponseBody(hr: http4s.Response[F]): http4s.Response[F] = {
val body = hr.headers
.get(http4s.headers.`Content-Encoding`)
.get[http4s.headers.`Content-Encoding`]
.map(e => customEncodingHandler.orElse(EncodingHandler(standardEncodingHandler))(hr.body -> e.contentCoding))
.getOrElse(hr.body)
hr.copy(body = body)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package sttp.client3.http4s

import cats.effect.IO
import org.http4s.blaze.client.BlazeClientBuilder
import sttp.client3.SttpBackend
import sttp.client3.impl.fs2.Fs2StreamingTest

import scala.concurrent.ExecutionContext
import org.http4s.client.blaze.BlazeClientBuilder
import sttp.capabilities.fs2.Fs2Streams

class Http4sHttpStreamingTest extends Fs2StreamingTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sttp.client3.http4s

import cats.effect.IO
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.blaze.client.BlazeClientBuilder
import sttp.client3.SttpBackend
import sttp.client3.impl.cats.CatsTestBase
import sttp.client3.testing.HttpTest
Expand Down

0 comments on commit dd14819

Please sign in to comment.