diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala b/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala index bf67a9681..a7c35dad4 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/internal/TemporaryInMemoryRepository.scala @@ -3,7 +3,7 @@ package lmcoursier.internal import java.io.{File, FileNotFoundException, IOException} import java.net.{HttpURLConnection, URL, URLConnection} -import coursier.cache.{CacheUrl, FileCache} +import coursier.cache.{ConnectionBuilder, FileCache} import coursier.core._ import coursier.util.{Artifact, EitherT, Monad} @@ -54,16 +54,14 @@ object TemporaryInMemoryRepository { var conn: URLConnection = null try { - conn = CacheUrl.urlConnection( - url.toString, - None, - followHttpToHttpsRedirections = cacheOpt.fold(false)(_.followHttpToHttpsRedirections), - followHttpsToHttpRedirections = cacheOpt.fold(false)(_.followHttpsToHttpRedirections), - sslSocketFactoryOpt = cacheOpt.flatMap(_.sslSocketFactoryOpt), - hostnameVerifierOpt = cacheOpt.flatMap(_.hostnameVerifierOpt), - method = "HEAD", - maxRedirectionsOpt = cacheOpt.flatMap(_.maxRedirections) - ) + conn = ConnectionBuilder(url.toURI.toASCIIString) + .withFollowHttpToHttpsRedirections(cacheOpt.fold(false)(_.followHttpToHttpsRedirections)) + .withFollowHttpsToHttpRedirections(cacheOpt.fold(false)(_.followHttpsToHttpRedirections)) + .withSslSocketFactoryOpt(cacheOpt.flatMap(_.sslSocketFactoryOpt)) + .withHostnameVerifierOpt(cacheOpt.flatMap(_.hostnameVerifierOpt)) + .withMethod("HEAD") + .withMaxRedirectionsOpt(cacheOpt.flatMap(_.maxRedirections)) + .connection() // Even though the finally clause handles this too, this has to be run here, so that we return Some(true) // iff this doesn't throw. conn.getInputStream.close()