diff --git a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2.scala b/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2.scala index 5b98dd84..ee83bf2d 100644 --- a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2.scala +++ b/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2.scala @@ -63,15 +63,11 @@ trait RequestBuilder { /** Adds the header. If the header has already been defined (e.g. from HeaderCarrier), it will be replaced. * It does not affect headers not mentioned. + * + * Use `transform(_.addHttpHeaders)` to append header values to existing. */ def setHeader(header: (String, String)*): RequestBuilder - @deprecated("Use setHeader", "14.5.0") - def replaceHeader(header: (String, String)): RequestBuilder - - @deprecated("Use setHeader to add or replace, or use transform(_.addHttpHeaders) to append header values to existing", "14.5.0") - def addHeaders(headers: (String, String)*): RequestBuilder - def withProxy: RequestBuilder /** `withBody` should be called rather than `transform(_.withBody)`. diff --git a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2Impl.scala b/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2Impl.scala index 9848dcaa..4a2ccc04 100644 --- a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2Impl.scala +++ b/http-verbs-play-30/src/main/scala/uk/gov/hmrc/http/client/HttpClientV2Impl.scala @@ -116,12 +116,6 @@ final class RequestBuilderImpl( override def setHeader(header: (String, String)*): RequestBuilderImpl = transform(replaceHeaderOnRequest(_, header: _*)) - override def replaceHeader(header: (String, String)): RequestBuilderImpl = - setHeader(header) - - override def addHeaders(headers: (String, String)*): RequestBuilderImpl = - transform(_.addHttpHeaders(headers: _*)) - override def withProxy: RequestBuilderImpl = transform(request => optProxyServer.foldLeft(request)(_ withProxyServer _)) diff --git a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/package.scala b/http-verbs-play-30/src/main/scala/uk/gov/hmrc/package.scala deleted file mode 100644 index 7cb7a3f5..00000000 --- a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/package.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2023 HM Revenue & Customs - * - * 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 uk.gov.hmrc - -package play { - - @deprecated("Use uk.gov.hmrc.play.http.HeaderCarrierConverter instead", "13.0.0") - object HeaderCarrierConverter extends uk.gov.hmrc.play.http.HeaderCarrierConverter -} diff --git a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/play/connectors/Connector.scala b/http-verbs-play-30/src/main/scala/uk/gov/hmrc/play/connectors/Connector.scala deleted file mode 100644 index a7f7b9dc..00000000 --- a/http-verbs-play-30/src/main/scala/uk/gov/hmrc/play/connectors/Connector.scala +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2023 HM Revenue & Customs - * - * 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 uk.gov.hmrc.play.connectors - -import com.typesafe.config.ConfigFactory -import play.api.libs.ws.{WSClient, WSRequest} -import uk.gov.hmrc.http.HeaderCarrier - -@deprecated("Use uk.gov.hmrc.play.http.ws.WSRequestBuilder", "13.0.0") -trait RequestBuilder { - def buildRequest(url: String)(implicit hc: HeaderCarrier): WSRequest -} - -@deprecated("Use uk.gov.hmrc.play.http.ws.WSRequest", "13.0.0") -trait WSClientRequestBuilder extends RequestBuilder { - def client: WSClient - - private val hcConfig = - HeaderCarrier.Config.fromConfig(ConfigFactory.load()) - - def buildRequest(url: String)(implicit hc: HeaderCarrier): WSRequest = - client.url(url) - .withHttpHeaders(hc.headersForUrl(hcConfig)(url): _*) -} diff --git a/http-verbs-play-30/src/test/scala/uk/gov/hmrc/play/connectors/ConnectorSpec.scala b/http-verbs-play-30/src/test/scala/uk/gov/hmrc/play/connectors/ConnectorSpec.scala deleted file mode 100644 index 4c85e54d..00000000 --- a/http-verbs-play-30/src/test/scala/uk/gov/hmrc/play/connectors/ConnectorSpec.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2023 HM Revenue & Customs - * - * 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 uk.gov.hmrc.play.connectors - -import org.scalatestplus.mockito.MockitoSugar -import org.scalatest.wordspec.AnyWordSpecLike -import org.scalatest.matchers.should.Matchers -import play.api.test.WsTestClient -import uk.gov.hmrc.http._ - -@annotation.nowarn("msg=deprecated") -class ConnectorSpec extends AnyWordSpecLike with Matchers with MockitoSugar { - WsTestClient.withClient { wsClient => - - "AuthConnector.buildRequest" should { - val builder = new WSClientRequestBuilder { - val client = wsClient - } - - s"add expected headers to the request" in { - val testAuthorisation = Authorization("someauth") - val forwarded = ForwardedFor("forwarded") - val sessionId = SessionId("session") - val requestId = RequestId("requestId") - val deviceID = "deviceIdTest" - - val hc = HeaderCarrier( - authorization = Some(testAuthorisation), - forwarded = Some(forwarded), - sessionId = Some(sessionId), - requestId = Some(requestId), - deviceID = Some(deviceID), - otherHeaders = Seq("path" -> "/the/request/path") - ) - - val request = builder.buildRequest("http://test.public.service/bar")(hc) - request.header(HeaderNames.authorisation) shouldBe Some(testAuthorisation.value) - request.header(HeaderNames.xForwardedFor) shouldBe Some(forwarded.value) - request.header(HeaderNames.xSessionId) shouldBe Some(sessionId.value) - request.header(HeaderNames.xRequestId) shouldBe Some(requestId.value) - request.header(HeaderNames.deviceID) shouldBe Some(deviceID) - request.header("path") shouldBe None - } - } - } -}