From d49ab99ef5820e511fd3edbd5e96de96b804fad2 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 12 Mar 2015 17:59:46 -0400
Subject: [PATCH] Update Jetty to 9.2.10
---
src/main/java/com/gitblit/manager/PluginManager.java | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/gitblit/manager/PluginManager.java b/src/main/java/com/gitblit/manager/PluginManager.java
index 5830375..b3936e5 100644
--- a/src/main/java/com/gitblit/manager/PluginManager.java
+++ b/src/main/java/com/gitblit/manager/PluginManager.java
@@ -15,13 +15,15 @@
*/
package com.gitblit.manager;
-import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
@@ -60,8 +62,7 @@
import com.gitblit.utils.FileUtils;
import com.gitblit.utils.JsonUtils;
import com.gitblit.utils.StringUtils;
-import com.google.common.io.Files;
-import com.google.common.io.InputSupplier;
+import com.google.common.io.ByteStreams;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -440,6 +441,10 @@
protected File download(String url, boolean verifyChecksum) throws IOException {
File file = downloadFile(url);
+ if (!verifyChecksum) {
+ return file;
+ }
+
File sha1File = null;
try {
sha1File = downloadFile(url + ".sha1");
@@ -453,7 +458,7 @@
}
- if (sha1File == null && md5File == null && verifyChecksum) {
+ if (sha1File == null && md5File == null) {
throw new IOException("Missing SHA1 and MD5 checksums for " + url);
}
@@ -528,12 +533,9 @@
// try to get the server-specified last-modified date of this artifact
long lastModified = conn.getHeaderFieldDate("Last-Modified", System.currentTimeMillis());
- Files.copy(new InputSupplier<InputStream>() {
- @Override
- public InputStream getInput() throws IOException {
- return new BufferedInputStream(conn.getInputStream());
- }
- }, tmpFile);
+ try (InputStream is = conn.getInputStream(); OutputStream os = new FileOutputStream(tmpFile);) {
+ ByteStreams.copy(is, os);
+ }
File destFile = new File(pFolder, StringUtils.getLastPathElement(u.getPath()));
if (destFile.exists()) {
@@ -582,11 +584,19 @@
}
protected Proxy getProxy(URL url) {
- return java.net.Proxy.NO_PROXY;
+ String proxyHost = runtimeManager.getSettings().getString(Keys.plugins.httpProxyHost, "");
+ String proxyPort = runtimeManager.getSettings().getString(Keys.plugins.httpProxyPort, "");
+
+ if (!StringUtils.isEmpty(proxyHost) && !StringUtils.isEmpty(proxyPort)) {
+ return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)));
+ } else {
+ return java.net.Proxy.NO_PROXY;
+ }
}
protected String getProxyAuthorization(URL url) {
- return "";
+ String proxyAuth = runtimeManager.getSettings().getString(Keys.plugins.httpProxyAuthorization, "");
+ return proxyAuth;
}
/**
--
Gitblit v1.9.1