From dd1481986917e3d8cdb798eb86b4496302c52643 Mon Sep 17 00:00:00 2001 From: adamw Date: Tue, 13 Jul 2021 15:23:47 +0200 Subject: [PATCH] Update http4s-ce2 to 0.22.0-RC1 --- build.sbt | 2 +- .../sttp/client3/http4s/Http4sBackend.scala | 16 +++++++++------- .../client3/http4s/Http4sHttpStreamingTest.scala | 2 +- .../sttp/client3/http4s/Http4sHttpTest.scala | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/build.sbt b/build.sbt index 75dd09d599..da583f1d42 100644 --- a/build.sbt +++ b/build.sbt @@ -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" diff --git a/http4s-ce2-backend/src/main/scala/sttp/client3/http4s/Http4sBackend.scala b/http4s-ce2-backend/src/main/scala/sttp/client3/http4s/Http4sBackend.scala index 7d6afffc25..ef574dfb33 100644 --- a/http4s-ce2-backend/src/main/scala/sttp/client3/http4s/Http4sBackend.scala +++ b/http4s-ce2-backend/src/main/scala/sttp/client3/http4s/Http4sBackend.scala @@ -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} @@ -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 @@ -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 ) @@ -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) @@ -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 { @@ -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) diff --git a/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpStreamingTest.scala b/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpStreamingTest.scala index 74e7cc98bf..c65157956e 100644 --- a/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpStreamingTest.scala +++ b/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpStreamingTest.scala @@ -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 { diff --git a/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpTest.scala b/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpTest.scala index 5256bc985b..1026d6d909 100644 --- a/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpTest.scala +++ b/http4s-ce2-backend/src/test/scala/sttp/client3/http4s/Http4sHttpTest.scala @@ -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