diff --git a/NOTICE b/NOTICE index f9d470850..274b02d96 100644 --- a/NOTICE +++ b/NOTICE @@ -9,3 +9,13 @@ Copyright 2005-2006 Dietmar Bürkle Portions of this software were contributed under section 5 of the Apache License. Contributors are listed under: http://barcode4j.sourceforge.net/contributors.html + +-------------------------------------------------------------------------------- +NOTICES FOR APACHE HTTPCOMPONENTS, COMMONS IO, COMMONS LANG, + COMMONS LOGGING, COMMONS FILEUPLOAD +-------------------------------------------------------------------------------- + +Copyright 1999-2012 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/zxingorg/src/com/google/zxing/web/DecodeServlet.java b/zxingorg/src/com/google/zxing/web/DecodeServlet.java index 5d51f525d..e34b1e95c 100644 --- a/zxingorg/src/com/google/zxing/web/DecodeServlet.java +++ b/zxingorg/src/com/google/zxing/web/DecodeServlet.java @@ -40,21 +40,12 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.http.Header; import org.apache.http.HttpMessage; import org.apache.http.HttpResponse; -import org.apache.http.HttpVersion; import org.apache.http.HttpEntity; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.conn.scheme.PlainSocketFactory; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.SingleClientConnManager; -import org.apache.http.params.BasicHttpParams; -import org.apache.http.params.HttpParams; -import org.apache.http.params.HttpProtocolParams; import org.apache.http.util.EntityUtils; import java.awt.color.CMMException; @@ -72,6 +63,7 @@ import java.util.EnumMap; import java.util.EnumSet; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; @@ -109,25 +101,15 @@ public final class DecodeServlet extends HttpServlet { HINTS_PURE.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE); } - private HttpParams params; - private SchemeRegistry registry; private DiskFileItemFactory diskFileItemFactory; + private HttpClient client; @Override public void init(ServletConfig servletConfig) { - Logger logger = Logger.getLogger("com.google.zxing"); logger.addHandler(new ServletContextLogHandler(servletConfig.getServletContext())); - - params = new BasicHttpParams(); - HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); - - registry = new SchemeRegistry(); - registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); - registry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory())); - diskFileItemFactory = new DiskFileItemFactory(); - + client = new DefaultHttpClient(); log.info("DecodeServlet configured"); } @@ -135,7 +117,7 @@ public final class DecodeServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String imageURIString = request.getParameter("u"); - if (imageURIString == null || imageURIString.length() == 0) { + if (imageURIString == null || imageURIString.isEmpty()) { log.fine("URI was empty"); response.sendRedirect("badurl.jspx"); return; @@ -158,9 +140,6 @@ public final class DecodeServlet extends HttpServlet { return; } - ClientConnectionManager connectionManager = new SingleClientConnManager(registry); - HttpClient client = new DefaultHttpClient(connectionManager, params); - HttpUriRequest getRequest = new HttpGet(imageURI); getRequest.addHeader("Connection", "close"); // Avoids CLOSE_WAIT socket issue? @@ -215,14 +194,16 @@ public final class DecodeServlet extends HttpServlet { } } finally { - connectionManager.shutdown(); + ClientConnectionManager connectionManager = client.getConnectionManager(); + connectionManager.closeExpiredConnections(); + connectionManager.closeIdleConnections(1, TimeUnit.SECONDS); } } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { if (!ServletFileUpload.isMultipartContent(request)) { log.fine("File upload was not multipart"); @@ -409,6 +390,7 @@ public final class DecodeServlet extends HttpServlet { @Override public void destroy() { log.config("DecodeServlet shutting down..."); + client.getConnectionManager().shutdown(); } } diff --git a/zxingorg/web/WEB-INF/lib/commons-io-1.4.jar b/zxingorg/web/WEB-INF/lib/commons-io-1.4.jar deleted file mode 100644 index 133dc6cb3..000000000 Binary files a/zxingorg/web/WEB-INF/lib/commons-io-1.4.jar and /dev/null differ diff --git a/zxingorg/web/WEB-INF/lib/commons-io-2.1.jar b/zxingorg/web/WEB-INF/lib/commons-io-2.1.jar new file mode 100644 index 000000000..b5c7d692f Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/commons-io-2.1.jar differ diff --git a/zxingorg/web/WEB-INF/lib/commons-lang-2.4.jar b/zxingorg/web/WEB-INF/lib/commons-lang-2.4.jar deleted file mode 100644 index 532939eca..000000000 Binary files a/zxingorg/web/WEB-INF/lib/commons-lang-2.4.jar and /dev/null differ diff --git a/zxingorg/web/WEB-INF/lib/commons-lang-2.6.jar b/zxingorg/web/WEB-INF/lib/commons-lang-2.6.jar new file mode 100644 index 000000000..98467d3a6 Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/commons-lang-2.6.jar differ diff --git a/zxingorg/web/WEB-INF/lib/fluent-hc-4.2-beta1.jar b/zxingorg/web/WEB-INF/lib/fluent-hc-4.2-beta1.jar new file mode 100644 index 000000000..afc4ae35c Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/fluent-hc-4.2-beta1.jar differ diff --git a/zxingorg/web/WEB-INF/lib/httpclient-4.1.2.jar b/zxingorg/web/WEB-INF/lib/httpclient-4.1.2.jar deleted file mode 100644 index b3cdb4cdc..000000000 Binary files a/zxingorg/web/WEB-INF/lib/httpclient-4.1.2.jar and /dev/null differ diff --git a/zxingorg/web/WEB-INF/lib/httpclient-4.2-beta1.jar b/zxingorg/web/WEB-INF/lib/httpclient-4.2-beta1.jar new file mode 100644 index 000000000..3be645ea0 Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/httpclient-4.2-beta1.jar differ diff --git a/zxingorg/web/WEB-INF/lib/httpclient-cache-4.2-beta1.jar b/zxingorg/web/WEB-INF/lib/httpclient-cache-4.2-beta1.jar new file mode 100644 index 000000000..c15c98b2f Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/httpclient-cache-4.2-beta1.jar differ diff --git a/zxingorg/web/WEB-INF/lib/httpcore-4.1.3.jar b/zxingorg/web/WEB-INF/lib/httpcore-4.1.3.jar deleted file mode 100644 index af56c7a06..000000000 Binary files a/zxingorg/web/WEB-INF/lib/httpcore-4.1.3.jar and /dev/null differ diff --git a/zxingorg/web/WEB-INF/lib/httpcore-4.2-beta1.jar b/zxingorg/web/WEB-INF/lib/httpcore-4.2-beta1.jar new file mode 100644 index 000000000..b920ccfa1 Binary files /dev/null and b/zxingorg/web/WEB-INF/lib/httpcore-4.2-beta1.jar differ diff --git a/zxingorg/web/WEB-INF/lib/httpcore-nio-4.1.3.jar b/zxingorg/web/WEB-INF/lib/httpcore-nio-4.1.3.jar deleted file mode 100644 index 0da1ca4e8..000000000 Binary files a/zxingorg/web/WEB-INF/lib/httpcore-nio-4.1.3.jar and /dev/null differ diff --git a/zxingorg/web/WEB-INF/lib/httpmime-4.1.2.jar b/zxingorg/web/WEB-INF/lib/httpmime-4.2-beta1.jar similarity index 75% rename from zxingorg/web/WEB-INF/lib/httpmime-4.1.2.jar rename to zxingorg/web/WEB-INF/lib/httpmime-4.2-beta1.jar index eea3b3ff1..aad1eacc9 100644 Binary files a/zxingorg/web/WEB-INF/lib/httpmime-4.1.2.jar and b/zxingorg/web/WEB-INF/lib/httpmime-4.2-beta1.jar differ