From 0526a0b571ba6048c25f6bf0f2fe1b8d44103d43 Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Thu, 11 Jan 2024 15:06:26 +0100 Subject: [PATCH 01/25] pin netty-reactive-streams-http to 2.x --- .scala-steward.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.scala-steward.conf b/.scala-steward.conf index 918bffda..a0ab6db0 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -1,4 +1,9 @@ updates.pin = [ { groupId = "org.slf4j", artifactId = "slf4j-api", version = "1." }, { groupId = "ch.qos.logback", artifactId = "logback-classic", version = "1.2." } + { groupId = "com.typesafe.netty", artifactId = "netty-reactive-streams-http", version = "2." } ] + +updates.ignore = [ + { groupId = "com.playframework.netty" } +] \ No newline at end of file From b5b58973d98b08cc4e448e0425193c8bd0b854c0 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 01:11:55 +0000 Subject: [PATCH 02/25] Update cats-effect to 3.5.3 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f8cc0edb..f8a83baa 100644 --- a/build.sbt +++ b/build.sbt @@ -52,7 +52,7 @@ lazy val core = project "io.netty" % "netty-codec-http" % netty, "io.netty" % "netty-handler" % netty, "org.http4s" %% "http4s-core" % http4sVersion, - "org.typelevel" %% "cats-effect" % "3.5.2" + "org.typelevel" %% "cats-effect" % "3.5.3" ) ) From c0f59c073513cc3e636a9c57cef5b66662409d99 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 16 Jan 2024 12:31:28 +0000 Subject: [PATCH 03/25] Update netty-codec-http, ... to 4.1.105.Final in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index f8a83baa..19890a2d 100644 --- a/build.sbt +++ b/build.sbt @@ -23,7 +23,7 @@ val http4sVersion = "0.23.25" val jetty = "12.0.5" -val netty = "4.1.104.Final" +val netty = "4.1.105.Final" val munit = "0.7.29" From 8e117397fac92900c60d10743f6588fb85b7c2b3 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:20:47 +0000 Subject: [PATCH 04/25] Update netty-codec-http, ... to 4.1.106.Final in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 19890a2d..2fbef6a7 100644 --- a/build.sbt +++ b/build.sbt @@ -23,7 +23,7 @@ val http4sVersion = "0.23.25" val jetty = "12.0.5" -val netty = "4.1.105.Final" +val netty = "4.1.106.Final" val munit = "0.7.29" From f296677160f40adbdf3facb899ab8acd52bbfe86 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Sat, 20 Jan 2024 20:17:07 +0000 Subject: [PATCH 05/25] Update fs2-reactive-streams to 3.9.4 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 19890a2d..ec4cfe98 100644 --- a/build.sbt +++ b/build.sbt @@ -45,7 +45,7 @@ lazy val core = project .settings( name := "http4s-netty-core", libraryDependencies ++= List( - "co.fs2" %% "fs2-reactive-streams" % "3.9.3", + "co.fs2" %% "fs2-reactive-streams" % "3.9.4", ("com.typesafe.netty" % "netty-reactive-streams-http" % "2.0.12") .exclude("io.netty", "netty-codec-http") .exclude("io.netty", "netty-handler"), From 6cf6780f7039b18ca0851b7397311d48f8cdbb92 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Mon, 22 Jan 2024 12:32:07 +0000 Subject: [PATCH 06/25] Update java-socks-proxy-server to 3.0.0 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 19890a2d..da8e3f27 100644 --- a/build.sbt +++ b/build.sbt @@ -110,7 +110,7 @@ lazy val client = project ("com.github.monkeywie" % "proxyee" % "1.7.6" % Test) .excludeAll("io.netty") .excludeAll("org.bouncycastle"), - "com.github.bbottema" % "java-socks-proxy-server" % "2.0.0" % Test, + "com.github.bbottema" % "java-socks-proxy-server" % "3.0.0" % Test, "org.scalameta" %% "munit" % munit % Test, "ch.qos.logback" % "logback-classic" % "1.2.13" % Test, "org.typelevel" %% "munit-cats-effect" % "2.0.0-M4" % Test From 5ebc75d0f90116567d56e50de18af24fd2ff3691 Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Wed, 31 Jan 2024 13:18:24 +0100 Subject: [PATCH 07/25] Make it possible to set default request headers Usefult headers may include User-Agent --- .../netty/client/Http4sChannelPoolMap.scala | 10 ++++---- .../netty/client/NettyClientBuilder.scala | 23 +++++++++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala index f5d90706..628f5f98 100644 --- a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala +++ b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala @@ -41,6 +41,7 @@ import io.netty.handler.ssl.ApplicationProtocolNames import io.netty.handler.ssl.SslHandler import io.netty.handler.timeout.IdleStateHandler import io.netty.util.concurrent.Future +import org.http4s.Headers import org.http4s.HttpVersion import org.http4s.Request import org.http4s.Response @@ -101,9 +102,9 @@ private[client] class Http4sChannelPoolMap[F[_]]( def run(request0: Request[F]): Resource[F, Response[F]] = { val request = - if (config.http2 && request0.uri.scheme.contains(Uri.Scheme.https)) - request0.withHttpVersion(HttpVersion.`HTTP/2`) - else request0 + (if (config.http2 && request0.uri.scheme.contains(Uri.Scheme.https)) + request0.withHttpVersion(HttpVersion.`HTTP/2`) + else request0).putHeaders(config.defaultRequestHeaders) val key = Key(RequestKey.fromRequest(request), request.httpVersion) for { @@ -241,7 +242,8 @@ private[client] object Http4sChannelPoolMap { idleTimeout: Duration, proxy: Option[Proxy], sslConfig: SSLContextOption, - http2: Boolean + http2: Boolean, + defaultRequestHeaders: Headers ) private[client] def fromFuture[F[_]: Async, A](future: => Future[A]): F[A] = diff --git a/client/src/main/scala/org/http4s/netty/client/NettyClientBuilder.scala b/client/src/main/scala/org/http4s/netty/client/NettyClientBuilder.scala index 41bdecb6..2c1fad0e 100644 --- a/client/src/main/scala/org/http4s/netty/client/NettyClientBuilder.scala +++ b/client/src/main/scala/org/http4s/netty/client/NettyClientBuilder.scala @@ -20,7 +20,9 @@ package client import cats.effect.Async import cats.effect.Resource import io.netty.bootstrap.Bootstrap +import org.http4s.Headers import org.http4s.client.Client +import org.http4s.headers.`User-Agent` import javax.net.ssl.SSLContext import scala.concurrent.duration._ @@ -36,7 +38,8 @@ class NettyClientBuilder[F[_]]( sslContext: SSLContextOption, nettyChannelOptions: NettyChannelOptions, proxy: Option[Proxy], - http2: Boolean + http2: Boolean, + defaultRequestHeaders: Headers )(implicit F: Async[F]) { type Self = NettyClientBuilder[F] @@ -51,7 +54,8 @@ class NettyClientBuilder[F[_]]( sslContext: SSLContextOption = sslContext, nettyChannelOptions: NettyChannelOptions = nettyChannelOptions, proxy: Option[Proxy] = proxy, - http2: Boolean = http2 + http2: Boolean = http2, + defaultRequestHeaders: Headers = defaultRequestHeaders ): NettyClientBuilder[F] = new NettyClientBuilder[F]( idleTimeout, @@ -64,7 +68,8 @@ class NettyClientBuilder[F[_]]( sslContext, nettyChannelOptions, proxy, - http2 + http2, + defaultRequestHeaders ) def withNativeTransport: Self = copy(transport = NettyTransport.defaultFor(Os.get)) @@ -102,6 +107,12 @@ class NettyClientBuilder[F[_]]( def withHttp2: Self = copy(http2 = true) def withoutHttp2: Self = copy(http2 = false) + def withUserAgent(useragent: `User-Agent`): NettyClientBuilder[F] = + copy(defaultRequestHeaders = defaultRequestHeaders.put(useragent)) + + def withDefaultRequestHeaders(headers: Headers): NettyClientBuilder[F] = + copy(defaultRequestHeaders = headers) + private def createBootstrap: Resource[F, Bootstrap] = Resource.make(F.delay { val bootstrap = new Bootstrap() @@ -122,7 +133,8 @@ class NettyClientBuilder[F[_]]( idleTimeout, proxy, sslContext, - http2 + http2, + defaultRequestHeaders ) Client[F](new Http4sChannelPoolMap[F](bs, config).run) } @@ -141,6 +153,7 @@ object NettyClientBuilder { sslContext = SSLContextOption.TryDefaultSSLContext, nettyChannelOptions = NettyChannelOptions.empty, proxy = Proxy.fromSystemProperties, - http2 = false + http2 = false, + defaultRequestHeaders = Headers() ) } From c5afde888be6ccfde091cd1ae60749ce1e3b6410 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:18:48 +0000 Subject: [PATCH 08/25] Update jetty-http2-client, ... to 12.0.6 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 15f5c2e8..2d4f07aa 100644 --- a/build.sbt +++ b/build.sbt @@ -21,7 +21,7 @@ inThisBuild( val http4sVersion = "0.23.25" -val jetty = "12.0.5" +val jetty = "12.0.6" val netty = "4.1.106.Final" From 7767f1ea5178345c339289b676b70eac32e911b0 Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Mon, 5 Feb 2024 08:34:41 +0100 Subject: [PATCH 09/25] request headers must override default headers --- .../scala/org/http4s/netty/client/Http4sChannelPoolMap.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala index 628f5f98..7cf528dd 100644 --- a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala +++ b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala @@ -104,7 +104,7 @@ private[client] class Http4sChannelPoolMap[F[_]]( val request = (if (config.http2 && request0.uri.scheme.contains(Uri.Scheme.https)) request0.withHttpVersion(HttpVersion.`HTTP/2`) - else request0).putHeaders(config.defaultRequestHeaders) + else request0).withHeaders(config.defaultRequestHeaders).putHeaders(request0.headers) val key = Key(RequestKey.fromRequest(request), request.httpVersion) for { From 79c070c6bc9214efb5761bf48059de19fd043e71 Mon Sep 17 00:00:00 2001 From: Frederic Samier Date: Fri, 9 Feb 2024 12:19:40 +0100 Subject: [PATCH 10/25] chore: add MacOS Aarch64 runtime dependency --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 2d4f07aa..e950fcbf 100644 --- a/build.sbt +++ b/build.sbt @@ -36,6 +36,7 @@ val nativeNettyModules = "io.netty.incubator" % "netty-incubator-transport-classes-io_uring" % io_uring, ("io.netty" % "netty-transport-native-epoll" % netty).classifier("linux-x86_64") % Runtime, ("io.netty" % "netty-transport-native-kqueue" % netty).classifier("osx-x86_64") % Runtime, + ("io.netty" % "netty-transport-native-kqueue" % netty).classifier("osx-aarch_64") % Runtime, ("io.netty.incubator" % "netty-incubator-transport-native-io_uring" % io_uring) .classifier("linux-x86_64") % Runtime ) From 1c73518bb10c543a507e5c37fa7e8cff383f28ae Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Fri, 9 Feb 2024 11:22:38 +0100 Subject: [PATCH 11/25] Add tests Override user agent and check that we get that back --- .../http4s/netty/client/EchoHeaderTest.scala | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 client/src/test/scala/org/http4s/netty/client/EchoHeaderTest.scala diff --git a/client/src/test/scala/org/http4s/netty/client/EchoHeaderTest.scala b/client/src/test/scala/org/http4s/netty/client/EchoHeaderTest.scala new file mode 100644 index 00000000..be260ebc --- /dev/null +++ b/client/src/test/scala/org/http4s/netty/client/EchoHeaderTest.scala @@ -0,0 +1,86 @@ +/* + * Copyright 2020 http4s.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.http4s.netty.client + +import cats.effect.IO +import com.comcast.ip4s._ +import munit.catseffect.IOFixture +import org.http4s.HttpRoutes +import org.http4s.ProductId +import org.http4s.Request +import org.http4s.Response +import org.http4s.client.Client +import org.http4s.dsl.io._ +import org.http4s.ember.server.EmberServerBuilder +import org.http4s.headers.`User-Agent` +import org.http4s.implicits._ +import org.http4s.server.Server + +import scala.concurrent.duration._ + +class EchoHeaderTest extends IOSuite { + private val defaultUserAgent: `User-Agent` = `User-Agent`(ProductId("http4s-client", Some("1.0"))) + val client: IOFixture[Client[IO]] = + resourceFixture( + NettyClientBuilder[IO] + .withIdleTimeout(10.seconds) + .withUserAgent(defaultUserAgent) + .resource, + "client") + + val server: IOFixture[Server] = resourceFixture( + EmberServerBuilder + .default[IO] + .withPort(port"0") + .withHttpApp( + HttpRoutes + .of[IO] { case r @ GET -> Root / "echo-ua" => + val ua = r.headers.get[`User-Agent`] + ua match { + case Some(value) => IO(Response[IO]().putHeaders(value)) + case None => NotFound() + } + } + .orNotFound + ) + .build, + "server" + ) + + test("echo useragent back") { + val s = server() + + client().get(s.baseUri / "echo-ua")(res => + res.headers.get[`User-Agent`] match { + case Some(value) => IO(assertEquals(value, defaultUserAgent)) + case None => IO(fail("No user-agent header found")) + }) + } + + test("echo useragent back override") { + val s = server() + + val overrideUA = `User-Agent`(ProductId("override")) + client() + .run(Request[IO](uri = s.baseUri / "echo-ua").putHeaders(overrideUA)) + .use(res => + res.headers.get[`User-Agent`] match { + case Some(value) => IO(assertEquals(value, overrideUA)) + case None => IO(fail("No user-agent header found")) + }) + } +} From cefbeb3f96b3b55dad887042ce5d7264e91d51f9 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 12:28:03 +0000 Subject: [PATCH 12/25] Update netty-codec-http, ... to 4.1.107.Final in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e950fcbf..af5c1676 100644 --- a/build.sbt +++ b/build.sbt @@ -23,7 +23,7 @@ val http4sVersion = "0.23.25" val jetty = "12.0.6" -val netty = "4.1.106.Final" +val netty = "4.1.107.Final" val munit = "0.7.29" From b7037e1e0059d57367c6b016028a22eba467a542 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:20:38 +0000 Subject: [PATCH 13/25] Update netty-incubator-transport-classes-io_uring, ... to 0.0.25.Final in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index af5c1676..8b11e39a 100644 --- a/build.sbt +++ b/build.sbt @@ -27,7 +27,7 @@ val netty = "4.1.107.Final" val munit = "0.7.29" -val io_uring = "0.0.24.Final" +val io_uring = "0.0.25.Final" val nativeNettyModules = Seq( From 25aae2b08464873dee9e0ba7c61c0ccca4f15aed Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:17:07 +0000 Subject: [PATCH 14/25] Update scalafmt-core to 3.8.0 in series/0.5 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 74bb091b..5c03b0ce 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.7.17 +version = 3.8.0 runner.dialect = scala213 style = default From 5eaab0fd9e37348b99dab8492ca747df96e476f1 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 08:24:16 +0000 Subject: [PATCH 15/25] Update sbt to 1.9.9 in series/0.5 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index abbbce5d..04267b14 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.8 +sbt.version=1.9.9 From ea888ac0b5c51199b6c95a53cc4443f348c84162 Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Mon, 26 Feb 2024 13:15:42 +0100 Subject: [PATCH 16/25] Fix idle timeout Incorrectly assumed that netty would throw an Exception --- .../http4s/netty/client/Http4sHandler.scala | 6 +- .../client/NettyClientIdleTimeoutTest.scala | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 client/src/test/scala/org/http4s/netty/client/NettyClientIdleTimeoutTest.scala diff --git a/client/src/main/scala/org/http4s/netty/client/Http4sHandler.scala b/client/src/main/scala/org/http4s/netty/client/Http4sHandler.scala index a02e5c4c..dd249bcf 100644 --- a/client/src/main/scala/org/http4s/netty/client/Http4sHandler.scala +++ b/client/src/main/scala/org/http4s/netty/client/Http4sHandler.scala @@ -32,6 +32,7 @@ import java.io.IOException import java.nio.channels.ClosedChannelException import scala.concurrent.ExecutionContext import scala.concurrent.Future +import scala.concurrent.TimeoutException import scala.util.Failure import scala.util.Success @@ -200,8 +201,9 @@ private[netty] class Http4sHandler[F[_]](dispatcher: Dispatcher[F])(implicit F: override def userEventTriggered(ctx: ChannelHandlerContext, evt: scala.Any): Unit = void { evt match { case _: IdleStateEvent if ctx.channel().isOpen => - logger.trace(s"Closing connection due to idle timeout") - ctx.channel().close() + val message = s"Closing connection due to idle timeout" + logger.trace(message) + onException(ctx.channel(), new TimeoutException(message)) case _ => super.userEventTriggered(ctx, evt) } } diff --git a/client/src/test/scala/org/http4s/netty/client/NettyClientIdleTimeoutTest.scala b/client/src/test/scala/org/http4s/netty/client/NettyClientIdleTimeoutTest.scala new file mode 100644 index 00000000..28891d45 --- /dev/null +++ b/client/src/test/scala/org/http4s/netty/client/NettyClientIdleTimeoutTest.scala @@ -0,0 +1,73 @@ +/* + * Copyright 2020 http4s.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.http4s.netty.client + +import cats.effect.IO +import com.comcast.ip4s._ +import munit.catseffect.IOFixture +import org.http4s.HttpRoutes +import org.http4s.Request +import org.http4s.Response +import org.http4s.client.Client +import org.http4s.dsl.io._ +import org.http4s.ember.server.EmberServerBuilder +import org.http4s.implicits._ +import org.http4s.server.Server + +import scala.concurrent.duration._ + +class NettyClientIdleTimeoutTest extends IOSuite { + override val munitIOTimeout: Duration = 1.minute + + val nettyClient: IOFixture[Client[IO]] = + resourceFixture( + NettyClientBuilder[IO] + .withIdleTimeout(2.seconds) + .resource, + "netty client") + + val server: IOFixture[Server] = resourceFixture( + EmberServerBuilder + .default[IO] + .withPort(port"0") + .withHttpApp( + HttpRoutes + .of[IO] { case GET -> Root / "idle-timeout" => + IO.sleep(30.seconds).as(Response()) + } + .orNotFound + ) + .build, + "server" + ) + + List( + (nettyClient, "netty client") + ).foreach { case (client, name) => + test(s"$name fails after idle timeout") { + val s = server() + + val req = Request[IO](uri = s.baseUri / "idle-timeout") + val response = client().run(req).allocated.attempt + IO.race(response, IO.sleep(5.seconds)).map { + case Left(Left(error)) => println(s"response failed, error:"); error.printStackTrace() + case Left(Right(_)) => println("response available") + case Right(_) => fail("idle timeout wasn't triggered") + } + } + } +} From 6bd125ef22c418e12387a04038679976b2ef9efb Mon Sep 17 00:00:00 2001 From: Erlend Hamnaberg Date: Mon, 26 Feb 2024 13:45:22 +0100 Subject: [PATCH 17/25] Hardening of unregistering the http4s handler --- .../org/http4s/netty/client/Http4sChannelPoolMap.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala index 7cf528dd..86cc0268 100644 --- a/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala +++ b/client/src/main/scala/org/http4s/netty/client/Http4sChannelPoolMap.scala @@ -119,7 +119,15 @@ private[client] class Http4sChannelPoolMap[F[_]]( } } { h => val pipeline = channel.pipeline() - F.delay(if (pipeline.toMap.containsKey("http4s")) void(pipeline.remove(h)) else ()) + F.delay { + if (pipeline.toMap.containsKey("http4s")) + try + void(pipeline.remove(h)) + catch { + case _: Throwable => () + } + else () + } } response <- handler.dispatch(request, channel, key) } yield response From 7487ee4597aff807802ae54dd3fcc56c274f61b7 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 08:27:25 +0000 Subject: [PATCH 18/25] Update sbt-http4s-org to 0.16.3 in series/0.5 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 13a30ceb..5799012f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.16.2") +addSbtPlugin("org.http4s" % "sbt-http4s-org" % "0.16.3") From a17a536afd40b93b750fbde647fdb1f8d342df40 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 08:27:51 +0000 Subject: [PATCH 19/25] Run prePR with sbt-typelevel Executed command: sbt tlPrePrBotHook --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab92cdce..fb4ac4d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,7 @@ jobs: - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} path: targets.tar @@ -123,7 +123,7 @@ jobs: run: sbt +update - name: Download target directories (2.13, rootJVM) - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: target-${{ matrix.os }}-${{ matrix.java }}-2.13-rootJVM @@ -133,7 +133,7 @@ jobs: rm targets.tar - name: Download target directories (2.12, rootJVM) - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: target-${{ matrix.os }}-${{ matrix.java }}-2.12-rootJVM @@ -143,7 +143,7 @@ jobs: rm targets.tar - name: Download target directories (3, rootJVM) - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: target-${{ matrix.os }}-${{ matrix.java }}-3-rootJVM From 723a5fd30e07c3a9c34e3132f5d83074adea8abd Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 01:14:20 +0000 Subject: [PATCH 20/25] Update scala-library to 2.12.19 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8b11e39a..edd7da81 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ import com.typesafe.tools.mima.core._ -val Scala212 = "2.12.18" +val Scala212 = "2.12.19" val Scala213 = "2.13.12" inThisBuild( From b0e813a248dbfb9d3933d2180c377d1802422ed2 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 01:14:39 +0000 Subject: [PATCH 21/25] Update scala-library to 2.13.13 in series/0.5 --- build.sbt | 2 +- .../test/scala/org/http4s/netty/client/HttpProxyTest.scala | 5 ++++- .../test/scala/org/http4s/netty/client/SocksProxyTest.scala | 5 ++++- .../main/scala/org/http4s/netty/NettyModelConversion.scala | 2 +- .../org/http4s/netty/server/ServerNettyModelConversion.scala | 5 +++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index edd7da81..3954b2d5 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ import com.typesafe.tools.mima.core._ val Scala212 = "2.12.19" -val Scala213 = "2.13.12" +val Scala213 = "2.13.13" inThisBuild( Seq( diff --git a/client/src/test/scala/org/http4s/netty/client/HttpProxyTest.scala b/client/src/test/scala/org/http4s/netty/client/HttpProxyTest.scala index 8098bea5..fad0bfd8 100644 --- a/client/src/test/scala/org/http4s/netty/client/HttpProxyTest.scala +++ b/client/src/test/scala/org/http4s/netty/client/HttpProxyTest.scala @@ -35,7 +35,10 @@ import scala.compat.java8.FutureConverters._ class HttpProxyTest extends IOSuite { val server: IOFixture[Uri] = resourceFixture( - ServerScaffold[IO](1, false, HttpRoutes.pure(Response[IO]().withEntity("Hello from origin"))) + ServerScaffold[IO]( + 1, + secure = false, + HttpRoutes.pure(Response[IO]().withEntity("Hello from origin"))) .map(_.servers.head.uri), "server") diff --git a/client/src/test/scala/org/http4s/netty/client/SocksProxyTest.scala b/client/src/test/scala/org/http4s/netty/client/SocksProxyTest.scala index 74b76cad..0f3da954 100644 --- a/client/src/test/scala/org/http4s/netty/client/SocksProxyTest.scala +++ b/client/src/test/scala/org/http4s/netty/client/SocksProxyTest.scala @@ -27,7 +27,10 @@ import org.http4s.client.testkit.scaffold.ServerScaffold class SocksProxyTest extends IOSuite { val server: IOFixture[Uri] = resourceFixture( - ServerScaffold[IO](1, false, HttpRoutes.pure(Response[IO]().withEntity("Hello from origin"))) + ServerScaffold[IO]( + 1, + secure = false, + HttpRoutes.pure(Response[IO]().withEntity("Hello from origin"))) .map(_.servers.head.uri), "server") diff --git a/core/src/main/scala/org/http4s/netty/NettyModelConversion.scala b/core/src/main/scala/org/http4s/netty/NettyModelConversion.scala index b3215985..a5545678 100644 --- a/core/src/main/scala/org/http4s/netty/NettyModelConversion.scala +++ b/core/src/main/scala/org/http4s/netty/NettyModelConversion.scala @@ -80,7 +80,7 @@ private[netty] class NettyModelConversion[F[_]](implicit F: Async[F]) { request.body.chunks .evalMap[F, HttpContent](buf => F.delay(chunkToNetty(buf)))).map { publisher => val streamedReq = new DefaultStreamedHttpRequest(version, method, uri, publisher) - transferEncoding(request.headers, false, streamedReq) + transferEncoding(request.headers, minorIs0 = false, streamedReq) streamedReq } } diff --git a/server/src/main/scala/org/http4s/netty/server/ServerNettyModelConversion.scala b/server/src/main/scala/org/http4s/netty/server/ServerNettyModelConversion.scala index 245eca88..d5bcb032 100644 --- a/server/src/main/scala/org/http4s/netty/server/ServerNettyModelConversion.scala +++ b/server/src/main/scala/org/http4s/netty/server/ServerNettyModelConversion.scala @@ -191,9 +191,10 @@ private[server] final class ServerNettyModelConversion[F[_]](implicit F: Async[F .handleErrorWith((_: Throwable) => Resource .eval(wsContext.failureResponse) - .flatMap(res => toNonWSResponse(httpRequest, res, httpVersion, dateString, true))) + .flatMap(res => + toNonWSResponse(httpRequest, res, httpVersion, dateString, minorVersionIs0 = true))) } else - toNonWSResponse(httpRequest, httpResponse, httpVersion, dateString, true) + toNonWSResponse(httpRequest, httpResponse, httpVersion, dateString, minorVersionIs0 = true) private[this] def appendAllToNetty(header: Header.Raw, nettyHeaders: HttpHeaders) = { nettyHeaders.add(header.name.toString, header.value) From e33ebf9eef9682bbdd3ac5ce08c718abb688d8bc Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 20:24:04 +0000 Subject: [PATCH 22/25] Update scala3-library to 3.3.3 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index edd7da81..37bc0e66 100644 --- a/build.sbt +++ b/build.sbt @@ -13,7 +13,7 @@ inThisBuild( licenses := Seq(License.Apache2), tlBaseVersion := "0.5", tlSonatypeUseLegacyHost := false, - crossScalaVersions := Seq(Scala213, Scala212, "3.3.1"), + crossScalaVersions := Seq(Scala213, Scala212, "3.3.3"), ThisBuild / scalaVersion := Scala213, githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17")) ) From 1523cae7cbda234d5003787b2cd6265c91f38787 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:20:55 +0000 Subject: [PATCH 23/25] Update http4s-circe, http4s-client, ... to 0.23.26 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index edd7da81..731f6f97 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,7 @@ inThisBuild( ) ) -val http4sVersion = "0.23.25" +val http4sVersion = "0.23.26" val jetty = "12.0.6" From f3878eae8b24cc6e43b37d6a9371bdd06244d355 Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 01:06:42 +0000 Subject: [PATCH 24/25] Update cats-effect to 3.5.4 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index edd7da81..9895ec0d 100644 --- a/build.sbt +++ b/build.sbt @@ -53,7 +53,7 @@ lazy val core = project "io.netty" % "netty-codec-http" % netty, "io.netty" % "netty-handler" % netty, "org.http4s" %% "http4s-core" % http4sVersion, - "org.typelevel" %% "cats-effect" % "3.5.3" + "org.typelevel" %% "cats-effect" % "3.5.4" ) ) From df161f9274bc032aa96c52accb9318108e11f2bf Mon Sep 17 00:00:00 2001 From: "http4s-steward[bot]" <106843772+http4s-steward[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:21:17 +0000 Subject: [PATCH 25/25] Update jetty-client to 12.0.7 in series/0.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 42faa7d9..5e042b87 100644 --- a/build.sbt +++ b/build.sbt @@ -21,7 +21,7 @@ inThisBuild( val http4sVersion = "0.23.26" -val jetty = "12.0.6" +val jetty = "12.0.7" val netty = "4.1.107.Final"