From 26bd2d23c5d1b2a620b606fcbd2403b138d95150 Mon Sep 17 00:00:00 2001 From: Christian Steinert Date: Wed, 22 Jul 2020 12:36:52 +0200 Subject: [PATCH] Corrects memozation of HttpHandlers. --- src/Paket.Core/Common/NetUtils.fs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Paket.Core/Common/NetUtils.fs b/src/Paket.Core/Common/NetUtils.fs index 4530c2a19d..46decf95c1 100644 --- a/src/Paket.Core/Common/NetUtils.fs +++ b/src/Paket.Core/Common/NetUtils.fs @@ -400,7 +400,13 @@ let createHttpHandlerRaw(url, auth: Auth option) : HttpMessageHandler = handler :> _ -let createHttpHandler = memoize createHttpHandlerRaw +let createHttpHandler = + memoizeBy + // Truncates the url to only to host part, so there is only one handler per source/host. + // 8 chars as startindex is chosen because `https://` is 8 chars long and we need the host delimiting `/`. + // For instance `https://api.nuget.org/v3/index.json` and `https://api.nuget.org/v3-flatcontainer/fsharp.core/index.json?semVerLevel=2.0.0` both get truncated to `https://api.nuget.org/` and share one handler (and one connection pool). + (fun (url : string, auth) -> url.Substring(0, url.IndexOf('/', 8) + 1), auth) + createHttpHandlerRaw let createHttpClient (url,auth:Auth option) : HttpClient = let handler = createHttpHandler (url, auth)