aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-10-05 12:32:38 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2020-10-06 19:03:36 -0400
commitf37aa182e14179479daf8a3a2a8240cd51912af1 (patch)
tree0c5ad12998b1aa6ac1c6c71a9cefc675c67f2da4 /org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java
parentb0b32501978c00018c3a046a09e474a1d783275a (diff)
downloadjgit-f37aa182e14179479daf8a3a2a8240cd51912af1.tar.gz
jgit-f37aa182e14179479daf8a3a2a8240cd51912af1.zip
Override config http.userAgent from environment GIT_HTTP_USER_AGENT
According to [1], environment variable GIT_HTTP_USER_AGENT can override a git config http.userAgent. [1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-httpuserAgent Change-Id: I996789dc49faf96339cd7b4e0a682b9bcafb6f70 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java
index 58fc250255..dc82f46197 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/HttpConfig.java
@@ -121,6 +121,8 @@ public class HttpConfig {
}
}).get().intValue();
+ private static final String ENV_HTTP_USER_AGENT = "GIT_HTTP_USER_AGENT"; //$NON-NLS-1$
+
/**
* Config values for http.followRedirect.
*/
@@ -364,6 +366,11 @@ public class HttpConfig {
saveCookies = config.getBoolean(HTTP, match, SAVE_COOKIES_KEY,
saveCookies);
}
+ // Environment overrides config
+ agent = SystemReader.getInstance().getenv(ENV_HTTP_USER_AGENT);
+ if (!StringUtils.isEmptyOrNull(agent)) {
+ userAgent = UserAgent.clean(agent);
+ }
postBuffer = postBufferSize;
sslVerify = sslVerifyFlag;
followRedirects = followRedirectsMode;