diff -r e34db561b7b9 netx/net/sourceforge/jnlp/cache/ResourceTracker.java --- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Mon Apr 29 16:24:37 2013 +0200 +++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Mon Apr 29 17:57:32 2013 +0200 @@ -49,6 +49,7 @@ import net.sourceforge.jnlp.event.DownloadEvent; import net.sourceforge.jnlp.event.DownloadListener; import net.sourceforge.jnlp.runtime.JNLPRuntime; +import net.sourceforge.jnlp.util.HttpUtils; import net.sourceforge.jnlp.util.StreamUtils; import net.sourceforge.jnlp.util.UrlUtils; import net.sourceforge.jnlp.util.WeakList; @@ -874,7 +875,7 @@ /* Fully consuming current request helps with connection re-use * See http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html */ - StreamUtils.consumeAndCloseInputStream(httpConnection.getInputStream()); + HttpUtils.consumeAndCloseConnectionSilently(httpConnection); return responseCode; } @@ -910,7 +911,7 @@ int responseCode = getUrlResponseCode(url, requestProperties, "HEAD"); - if (responseCode == HttpURLConnection.HTTP_NOT_IMPLEMENTED ) { + if (responseCode < 200 || responseCode >= 300) { System.err.println("NOTE: The server does not appear to support HEAD requests, falling back to GET requests."); /* Fallback: use GET request in the rare case the server does not support HEAD requests */ responseCode = getUrlResponseCode(url, requestProperties, "GET"); diff -r e34db561b7b9 netx/net/sourceforge/jnlp/util/HttpUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/netx/net/sourceforge/jnlp/util/HttpUtils.java Mon Apr 29 17:57:32 2013 +0200 @@ -0,0 +1,64 @@ +/* + Copyright (C) 2011 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. +*/ +package net.sourceforge.jnlp.util; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; + + +public class HttpUtils { + + + /** + * Ensure a HttpURLConnection is fully read, required for correct behaviour in some + * APIs, namely HttpURLConnection. + */ + public static void consumeAndCloseConnectionSilently(HttpURLConnection c) { + try { + InputStream in = c.getInputStream(); + byte[] throwAwayBuffer = new byte[256]; + while (in.read(throwAwayBuffer) > 0) { + /* ignore contents */ + } + in.close(); + } catch (IOException ex) { + ex.printStackTrace(System.err); + } + } + +} diff -r e34db561b7b9 netx/net/sourceforge/jnlp/util/StreamUtils.java --- a/netx/net/sourceforge/jnlp/util/StreamUtils.java Mon Apr 29 16:24:37 2013 +0200 +++ b/netx/net/sourceforge/jnlp/util/StreamUtils.java Mon Apr 29 17:57:32 2013 +0200 @@ -42,22 +42,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.HttpURLConnection; public class StreamUtils { - /** - * Ensure a stream is fully read, required for correct behaviour in some - * APIs, namely HttpURLConnection. - * @throws IOException - */ - public static void consumeAndCloseInputStream(InputStream in) throws IOException { - byte[] throwAwayBuffer = new byte[256]; - while (in.read(throwAwayBuffer) > 0) { - /* ignore contents */ - } - in.close(); - } - /*** * Closes a stream, without throwing IOException. * In case of IOException, prints the stack trace to System.err.