From c89a727179eacf0efb10f3f58a3bbec3543567aa Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 21:41:41 +0100 Subject: [PATCH 01/12] attempting to add headers and add test --- .../com/cognite/sdk/scala/v1/Client.scala | 16 +++++- .../com/cognite/sdk/scala/v1/ClientTest.scala | 56 ++++++++++++++++--- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala index 905738569..320d270a7 100644 --- a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala +++ b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala @@ -3,18 +3,19 @@ package com.cognite.sdk.scala.v1 -import com.cognite.scala_sdk.BuildInfo import cats.implicits._ import cats.{Id, Monad} +import com.cognite.scala_sdk.BuildInfo import com.cognite.sdk.scala.common._ import com.cognite.sdk.scala.v1.GenericClient.parseResponse import com.cognite.sdk.scala.v1.resources._ -import com.cognite.sdk.scala.v1.resources.fdm.datamodels.{DataModels => DataModelsV3} import com.cognite.sdk.scala.v1.resources.fdm.containers.Containers +import com.cognite.sdk.scala.v1.resources.fdm.datamodels.{DataModels => DataModelsV3} import com.cognite.sdk.scala.v1.resources.fdm.instances.Instances import com.cognite.sdk.scala.v1.resources.fdm.views.Views import io.circe.Decoder import io.circe.generic.semiauto.deriveDecoder +import natchez.Trace import sttp.capabilities.Effect import sttp.client3._ import sttp.client3.circe.asJsonEither @@ -24,7 +25,6 @@ import sttp.monad.MonadError import java.net.{InetAddress, UnknownHostException} import scala.concurrent.duration._ import scala.util.control.NonFatal -import natchez.Trace class TraceSttpBackend[F[_]: Trace, +P](delegate: SttpBackend[F, P]) extends SttpBackend[F, P] { @@ -147,6 +147,16 @@ final case class RequestSession[F[_]: Monad: Trace]( .send(sttpBackend) .map(_.body) + def head( + uri: Uri, + headers: Seq[Header] = Seq() + ): F[Seq[Header]] = + sttpRequest + .headers(headers: _*) + .head(uri) + .send(sttpBackend) + .map(_.headers) + def sendCdf[R]( r: RequestT[Empty, Either[String, String], Any] => RequestT[Id, R, Any], contentType: String = "application/json", diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index 5e59c3045..d0644908c 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -3,14 +3,10 @@ package com.cognite.sdk.scala.v1 -import com.cognite.scala_sdk.BuildInfo - -import java.net.{ConnectException, UnknownHostException} -import java.time.Instant -import java.util.Base64 -import cats.effect._ import cats.Id +import cats.effect._ import cats.effect.std.Queue +import com.cognite.scala_sdk.BuildInfo import com.cognite.sdk.scala.common._ import com.cognite.sdk.scala.sttp.{BackpressureThrottleBackend, RateLimitingBackend, RetryingBackend} import org.scalatest.OptionValues @@ -21,11 +17,18 @@ import sttp.client3.{Response, SttpBackend, SttpClientException, UriContext, bas import sttp.model.{Header, StatusCode} import sttp.monad.MonadAsyncError -import scala.collection.immutable.Seq +import java.net.{ConnectException, UnknownHostException} +import java.time.Instant +import java.util.Base64 import scala.concurrent.TimeoutException import scala.concurrent.duration._ -@SuppressWarnings(Array("org.wartremover.warts.NonUnitStatements", "org.wartremover.warts.Var")) +@SuppressWarnings(Array( + "org.wartremover.warts.NonUnitStatements", + "org.wartremover.warts.Var", + "org.wartremover.warts.ThreadSleep", + "org.wartremover.warts.While") +) class ClientTest extends SdkTestSpec with OptionValues { private val tokenInspectResponse = Response( s""" @@ -416,4 +419,41 @@ class ClientTest extends SdkTestSpec with OptionValues { } } + it should "send a head request and return the headers" in { + client.requestSession.head(uri"https://www.cognite.com/").unsafeRunSync() should not be(empty) + } + + + it should "send a head request and return the headers with header" in { + //we create a file and send it in order to be able to check content encoding on the file upload link side of things + val file = + client.files.upload( + new java.io.File("./src/test/scala/com/cognite/sdk/scala/v1/uploadTest.txt") + ).unsafeRunSync() + + + var uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() + var retryCount = 0 + while (!uploadedFile.headOption + .getOrElse(throw new RuntimeException("File was not uploaded in test")) + .uploaded) { + retryCount += 1 + Thread.sleep(500) + uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() + if (retryCount > 10) { + throw new RuntimeException("File is not uploaded after 10 retries in test") + } + } + + val link = client.files.downloadLink(FileDownloadId(file.id)).unsafeRunSync() + + val headers = client.requestSession.head(uri"$link", Seq(Header("Accept-Encoding", "gzip"))).unsafeRunSync() + val headers2 = client.requestSession.head(uri"$link").unsafeRunSync() + headers should contain(headers2) + + link.downloadUrl shouldNot be(empty) + client.files.deleteById(file.id).unsafeRunSync() + + } + } From 8c8ce565d26a0e859063435f96c1286c258d7799 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 21:49:42 +0100 Subject: [PATCH 02/12] ups --- src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index d0644908c..5c9251498 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -447,7 +447,7 @@ class ClientTest extends SdkTestSpec with OptionValues { val link = client.files.downloadLink(FileDownloadId(file.id)).unsafeRunSync() - val headers = client.requestSession.head(uri"$link", Seq(Header("Accept-Encoding", "gzip"))).unsafeRunSync() + val headers = client.requestSession.head(uri"$link", Seq(Header("Accept-Encoding", ""))).unsafeRunSync() val headers2 = client.requestSession.head(uri"$link").unsafeRunSync() headers should contain(headers2) From 00b8c591270cb6f6dc3be3446465e37baac85030 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 21:50:12 +0100 Subject: [PATCH 03/12] change headers, fix test --- src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index 5c9251498..a49486878 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -426,6 +426,7 @@ class ClientTest extends SdkTestSpec with OptionValues { it should "send a head request and return the headers with header" in { //we create a file and send it in order to be able to check content encoding on the file upload link side of things + //what we want to check is that this header, which is set by default, can be overriden to empty val file = client.files.upload( new java.io.File("./src/test/scala/com/cognite/sdk/scala/v1/uploadTest.txt") @@ -447,8 +448,8 @@ class ClientTest extends SdkTestSpec with OptionValues { val link = client.files.downloadLink(FileDownloadId(file.id)).unsafeRunSync() - val headers = client.requestSession.head(uri"$link", Seq(Header("Accept-Encoding", ""))).unsafeRunSync() - val headers2 = client.requestSession.head(uri"$link").unsafeRunSync() + val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", ""))).unsafeRunSync() + val headers2 = client.requestSession.head(uri"${link.downloadUrl}").unsafeRunSync() headers should contain(headers2) link.downloadUrl shouldNot be(empty) From 5360787b2aa0254551a351b0ad44c4a974e69669 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 21:58:35 +0100 Subject: [PATCH 04/12] better headers --- src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index a49486878..b788a64b1 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -450,7 +450,8 @@ class ClientTest extends SdkTestSpec with OptionValues { val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", ""))).unsafeRunSync() val headers2 = client.requestSession.head(uri"${link.downloadUrl}").unsafeRunSync() - headers should contain(headers2) + + headers.filter(_.name == "Content-Encoding") should contain theSameElementsAs headers2.filter(_.name == "Content-Encoding") link.downloadUrl shouldNot be(empty) client.files.deleteById(file.id).unsafeRunSync() From 55bb2ce230969952928be6044346a95793c36dbd Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 21:59:32 +0100 Subject: [PATCH 05/12] ignore case --- src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index b788a64b1..4a306c4a3 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -451,7 +451,7 @@ class ClientTest extends SdkTestSpec with OptionValues { val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", ""))).unsafeRunSync() val headers2 = client.requestSession.head(uri"${link.downloadUrl}").unsafeRunSync() - headers.filter(_.name == "Content-Encoding") should contain theSameElementsAs headers2.filter(_.name == "Content-Encoding") + headers.filter(_.name.equalsIgnoreCase("Content-Encoding")) should contain theSameElementsAs headers2.filter(_.name.equalsIgnoreCase("Content-Encoding")) link.downloadUrl shouldNot be(empty) client.files.deleteById(file.id).unsafeRunSync() From e0e2014534ce81e3c51314a98cbe4be378374637 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 22:06:27 +0100 Subject: [PATCH 06/12] perhaps if I explicitely forbit the identity encoding? --- src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index 4a306c4a3..098f7a260 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -448,7 +448,7 @@ class ClientTest extends SdkTestSpec with OptionValues { val link = client.files.downloadLink(FileDownloadId(file.id)).unsafeRunSync() - val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", ""))).unsafeRunSync() + val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", "deflate, identity;q=0"))).unsafeRunSync() val headers2 = client.requestSession.head(uri"${link.downloadUrl}").unsafeRunSync() headers.filter(_.name.equalsIgnoreCase("Content-Encoding")) should contain theSameElementsAs headers2.filter(_.name.equalsIgnoreCase("Content-Encoding")) From 543ba9de5bc316b12db5c9ca6d788a60dc9015be Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 22:37:26 +0100 Subject: [PATCH 07/12] check which headers are sent --- .../com/cognite/sdk/scala/v1/Client.scala | 7 ++-- .../com/cognite/sdk/scala/v1/ClientTest.scala | 39 +++---------------- 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala index 320d270a7..4da4a58fc 100644 --- a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala +++ b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala @@ -150,12 +150,13 @@ final case class RequestSession[F[_]: Monad: Trace]( def head( uri: Uri, headers: Seq[Header] = Seq() - ): F[Seq[Header]] = + ): F[Any] = sttpRequest .headers(headers: _*) - .head(uri) + .get(uri) .send(sttpBackend) - .map(_.headers) + .map(_.body) + def sendCdf[R]( r: RequestT[Empty, Either[String, String], Any] => RequestT[Id, R, Any], diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index 098f7a260..b75df96e8 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -419,43 +419,16 @@ class ClientTest extends SdkTestSpec with OptionValues { } } - it should "send a head request and return the headers" in { - client.requestSession.head(uri"https://www.cognite.com/").unsafeRunSync() should not be(empty) - } +// it should "send a head request and return the headers" in { +// client.requestSession.head(uri"https://www.cognite.com/").unsafeRunSync() should not be(empty) +// } it should "send a head request and return the headers with header" in { - //we create a file and send it in order to be able to check content encoding on the file upload link side of things - //what we want to check is that this header, which is set by default, can be overriden to empty - val file = - client.files.upload( - new java.io.File("./src/test/scala/com/cognite/sdk/scala/v1/uploadTest.txt") - ).unsafeRunSync() - - - var uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() - var retryCount = 0 - while (!uploadedFile.headOption - .getOrElse(throw new RuntimeException("File was not uploaded in test")) - .uploaded) { - retryCount += 1 - Thread.sleep(500) - uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() - if (retryCount > 10) { - throw new RuntimeException("File is not uploaded after 10 retries in test") - } - } - - val link = client.files.downloadLink(FileDownloadId(file.id)).unsafeRunSync() - - val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", "deflate, identity;q=0"))).unsafeRunSync() - val headers2 = client.requestSession.head(uri"${link.downloadUrl}").unsafeRunSync() - - headers.filter(_.name.equalsIgnoreCase("Content-Encoding")) should contain theSameElementsAs headers2.filter(_.name.equalsIgnoreCase("Content-Encoding")) - - link.downloadUrl shouldNot be(empty) - client.files.deleteById(file.id).unsafeRunSync() + val headers = client.requestSession.head(uri"https://postman-echo.com/headers", Seq(Header("Accept-Encoding", "gzip"))).unsafeRunSync() + val headers2 = client.requestSession.head(uri"https://postman-echo.com/headers").unsafeRunSync() + headers should be(headers2) } } From ca984e874ecd82a2336f04a8308634549f77b4d6 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 22:38:53 +0100 Subject: [PATCH 08/12] Revert "check which headers are sent" This reverts commit 543ba9de5bc316b12db5c9ca6d788a60dc9015be. --- .../com/cognite/sdk/scala/v1/Client.scala | 7 ++-- .../com/cognite/sdk/scala/v1/ClientTest.scala | 39 ++++++++++++++++--- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala index 4da4a58fc..320d270a7 100644 --- a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala +++ b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala @@ -150,13 +150,12 @@ final case class RequestSession[F[_]: Monad: Trace]( def head( uri: Uri, headers: Seq[Header] = Seq() - ): F[Any] = + ): F[Seq[Header]] = sttpRequest .headers(headers: _*) - .get(uri) + .head(uri) .send(sttpBackend) - .map(_.body) - + .map(_.headers) def sendCdf[R]( r: RequestT[Empty, Either[String, String], Any] => RequestT[Id, R, Any], diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index b75df96e8..098f7a260 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -419,16 +419,43 @@ class ClientTest extends SdkTestSpec with OptionValues { } } -// it should "send a head request and return the headers" in { -// client.requestSession.head(uri"https://www.cognite.com/").unsafeRunSync() should not be(empty) -// } + it should "send a head request and return the headers" in { + client.requestSession.head(uri"https://www.cognite.com/").unsafeRunSync() should not be(empty) + } it should "send a head request and return the headers with header" in { - val headers = client.requestSession.head(uri"https://postman-echo.com/headers", Seq(Header("Accept-Encoding", "gzip"))).unsafeRunSync() - val headers2 = client.requestSession.head(uri"https://postman-echo.com/headers").unsafeRunSync() + //we create a file and send it in order to be able to check content encoding on the file upload link side of things + //what we want to check is that this header, which is set by default, can be overriden to empty + val file = + client.files.upload( + new java.io.File("./src/test/scala/com/cognite/sdk/scala/v1/uploadTest.txt") + ).unsafeRunSync() + + + var uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() + var retryCount = 0 + while (!uploadedFile.headOption + .getOrElse(throw new RuntimeException("File was not uploaded in test")) + .uploaded) { + retryCount += 1 + Thread.sleep(500) + uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() + if (retryCount > 10) { + throw new RuntimeException("File is not uploaded after 10 retries in test") + } + } + + val link = client.files.downloadLink(FileDownloadId(file.id)).unsafeRunSync() + + val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", "deflate, identity;q=0"))).unsafeRunSync() + val headers2 = client.requestSession.head(uri"${link.downloadUrl}").unsafeRunSync() + + headers.filter(_.name.equalsIgnoreCase("Content-Encoding")) should contain theSameElementsAs headers2.filter(_.name.equalsIgnoreCase("Content-Encoding")) + + link.downloadUrl shouldNot be(empty) + client.files.deleteById(file.id).unsafeRunSync() - headers should be(headers2) } } From b53925f3ca6c71329315e52114b94ed8e928f377 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 22:40:04 +0100 Subject: [PATCH 09/12] no more override on headers --- .../com/cognite/sdk/scala/v1/ClientTest.scala | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index 098f7a260..93b838870 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -422,40 +422,4 @@ class ClientTest extends SdkTestSpec with OptionValues { it should "send a head request and return the headers" in { client.requestSession.head(uri"https://www.cognite.com/").unsafeRunSync() should not be(empty) } - - - it should "send a head request and return the headers with header" in { - //we create a file and send it in order to be able to check content encoding on the file upload link side of things - //what we want to check is that this header, which is set by default, can be overriden to empty - val file = - client.files.upload( - new java.io.File("./src/test/scala/com/cognite/sdk/scala/v1/uploadTest.txt") - ).unsafeRunSync() - - - var uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() - var retryCount = 0 - while (!uploadedFile.headOption - .getOrElse(throw new RuntimeException("File was not uploaded in test")) - .uploaded) { - retryCount += 1 - Thread.sleep(500) - uploadedFile = client.files.retrieveByIds(Seq(file.id)).unsafeRunSync() - if (retryCount > 10) { - throw new RuntimeException("File is not uploaded after 10 retries in test") - } - } - - val link = client.files.downloadLink(FileDownloadId(file.id)).unsafeRunSync() - - val headers = client.requestSession.head(uri"${link.downloadUrl}", Seq(Header("Accept-Encoding", "deflate, identity;q=0"))).unsafeRunSync() - val headers2 = client.requestSession.head(uri"${link.downloadUrl}").unsafeRunSync() - - headers.filter(_.name.equalsIgnoreCase("Content-Encoding")) should contain theSameElementsAs headers2.filter(_.name.equalsIgnoreCase("Content-Encoding")) - - link.downloadUrl shouldNot be(empty) - client.files.deleteById(file.id).unsafeRunSync() - - } - } From d9d3eb744625d9c46ec2796781e3af4480731076 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 22:41:53 +0100 Subject: [PATCH 10/12] cleanup tests --- src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index 93b838870..6dd2f2e6e 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -23,12 +23,7 @@ import java.util.Base64 import scala.concurrent.TimeoutException import scala.concurrent.duration._ -@SuppressWarnings(Array( - "org.wartremover.warts.NonUnitStatements", - "org.wartremover.warts.Var", - "org.wartremover.warts.ThreadSleep", - "org.wartremover.warts.While") -) +@SuppressWarnings(Array("org.wartremover.warts.NonUnitStatements", "org.wartremover.warts.Var")) class ClientTest extends SdkTestSpec with OptionValues { private val tokenInspectResponse = Response( s""" From 340d6e199b4b5a528f028882c06b03153c246a67 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Wed, 30 Oct 2024 22:47:14 +0100 Subject: [PATCH 11/12] re-add collection.immutable.Seq for compilation in 2.12 --- src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala index 6dd2f2e6e..ea21c7b8c 100644 --- a/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala +++ b/src/test/scala/com/cognite/sdk/scala/v1/ClientTest.scala @@ -22,6 +22,7 @@ import java.time.Instant import java.util.Base64 import scala.concurrent.TimeoutException import scala.concurrent.duration._ +import scala.collection.immutable.Seq @SuppressWarnings(Array("org.wartremover.warts.NonUnitStatements", "org.wartremover.warts.Var")) class ClientTest extends SdkTestSpec with OptionValues { From 41c1edbec37b7cdb6770af89428e50c00c53d745 Mon Sep 17 00:00:00 2001 From: Jacob Eliat-Eliat Date: Thu, 31 Oct 2024 14:28:54 +0100 Subject: [PATCH 12/12] override headers instead of just headers for clarity --- src/main/scala/com/cognite/sdk/scala/v1/Client.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala index 320d270a7..a2e723455 100644 --- a/src/main/scala/com/cognite/sdk/scala/v1/Client.scala +++ b/src/main/scala/com/cognite/sdk/scala/v1/Client.scala @@ -149,10 +149,10 @@ final case class RequestSession[F[_]: Monad: Trace]( def head( uri: Uri, - headers: Seq[Header] = Seq() + overrideHeaders: Seq[Header] = Seq() ): F[Seq[Header]] = sttpRequest - .headers(headers: _*) + .headers(overrideHeaders: _*) .head(uri) .send(sttpBackend) .map(_.headers)