From d773b9d723691de1f7066dc4ebde97c9e2be9a71 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 5 Aug 2003 06:54:01 +0000 Subject: [PATCH] Properly handle errors and do the right thing if we have no version specified (which should fix versionless dynamic downloads). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2740 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/resource/JNLPDownloader.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/resource/JNLPDownloader.java b/src/java/com/threerings/resource/JNLPDownloader.java index c8ff3ded9..4d3a8c92e 100644 --- a/src/java/com/threerings/resource/JNLPDownloader.java +++ b/src/java/com/threerings/resource/JNLPDownloader.java @@ -1,5 +1,5 @@ // -// $Id: JNLPDownloader.java,v 1.1 2003/08/05 01:33:20 mdb Exp $ +// $Id: JNLPDownloader.java,v 1.2 2003/08/05 06:54:01 mdb Exp $ package com.threerings.resource; @@ -75,7 +75,8 @@ public class JNLPDownloader extends Downloader ucon.connect(); // make sure we got a satisfactory response code - if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) { + if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK || + JNLP_ERROR_TYPE.equals(ucon.getContentType())) { String errmsg = "Unable to check up-to-date for " + getResourceURL() + ": " + ucon.getResponseCode(); throw new IOException(errmsg); @@ -101,7 +102,8 @@ public class JNLPDownloader extends Downloader ucon.connect(); // make sure we got a satisfactory response code - if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK) { + if (ucon.getResponseCode() != HttpURLConnection.HTTP_OK || + JNLP_ERROR_TYPE.equals(ucon.getContentType())) { String errmsg = "Unable to download update for " + getResourceURL() + ": " + ucon.getResponseCode(); throw new IOException(errmsg); @@ -182,6 +184,9 @@ public class JNLPDownloader extends Downloader */ protected URL getResourceURL () { + if (_desc.version == null) { + return _desc.sourceURL; + } URL rsrcURL = _desc.sourceURL; String vargs = _desc.sourceURL.getPath() + "?version-id=" + _desc.version; @@ -233,4 +238,9 @@ public class JNLPDownloader extends Downloader /** The mime-type of a jardiff patch file. */ protected static final String JARDIFF_TYPE = "application/x-java-archive-diff"; + + /** The mime-type indicating a jnlp-servlet error. Why they don't just + * use an HTTP error response code, I dare not attempt to imagine. */ + protected static final String JNLP_ERROR_TYPE = + "application/x-java-jnlp-error"; }