From 0e707a49fc3a788a81fab80364616e989168a933 Mon Sep 17 00:00:00 2001
From: Sergio Zharinov <zharinov@users.noreply.github.com>
Date: Tue, 7 Apr 2020 18:40:25 +0400
Subject: [PATCH] fix(maven): Use different Http instances per hostType (#5900)

---
 lib/datasource/maven/util.ts | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/datasource/maven/util.ts b/lib/datasource/maven/util.ts
index a80701dc5e..bfbca79f56 100644
--- a/lib/datasource/maven/util.ts
+++ b/lib/datasource/maven/util.ts
@@ -5,7 +5,14 @@ import { DatasourceError } from '../common';
 
 import { id, MAVEN_REPO } from './common';
 
-const http = new Http(id);
+const http: Record<string, Http> = {};
+
+function httpByHostType(hostType: string): Http {
+  if (!http[hostType]) {
+    http[hostType] = new Http(hostType);
+  }
+  return http[hostType];
+}
 
 const getHost = (x: string): string => new url.URL(x).host;
 
@@ -46,7 +53,8 @@ export async function downloadHttpProtocol(
 ): Promise<string | null> {
   let raw: { body: string };
   try {
-    raw = await http.get(pkgUrl.toString());
+    const httpClient = httpByHostType(hostType);
+    raw = await httpClient.get(pkgUrl.toString());
   } catch (err) {
     const failedUrl = pkgUrl.toString();
     if (isNotFoundError(err)) {
-- 
GitLab