- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 17 Sep 2009 16:54:02 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/input In directory hutz:/tmp/cvs-serv5733/src/org/w3c/unicorn/input Modified Files: URIInputParameter.java Log Message: fixed unauthorized access error not reachable Index: URIInputParameter.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/input/URIInputParameter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- URIInputParameter.java 17 Sep 2009 16:48:44 -0000 1.2 +++ URIInputParameter.java 17 Sep 2009 16:54:00 -0000 1.3 @@ -7,7 +7,6 @@ import java.net.MalformedURLException; import java.net.SocketTimeoutException; import java.net.URL; -import java.net.URLConnection; import java.net.UnknownHostException; import javax.activation.MimeType; @@ -34,9 +33,18 @@ URL docUrl = null; try { docUrl = new URL(uri); - URLConnection con = docUrl.openConnection(); + HttpURLConnection con = (HttpURLConnection) docUrl.openConnection(); con.setConnectTimeout(connectTimeOut); con.connect(); + + Message message; + int responseCode = con.getResponseCode(); + switch (responseCode) { + case HttpURLConnection.HTTP_UNAUTHORIZED: + message = new Message(Message.Level.ERROR, "$message_unauthorized_access", null); + throw new UnicornException(message); + } + String sMimeType = con.getContentType(); sMimeType = sMimeType.split(";")[0]; mimeType = new MimeType(sMimeType); @@ -68,24 +76,8 @@ throw new UnicornException(message); } } catch (IOException e) { - try { - int responseCode; - if (docUrl != null) { - responseCode = ((HttpURLConnection) docUrl.openConnection()).getResponseCode(); - Message message; - switch (responseCode) { - case HttpURLConnection.HTTP_UNAUTHORIZED: - message = new Message(Message.Level.ERROR, "$message_unauthorized_access", null); - throw new UnicornException(message); - default: - message = new Message(e); - throw new UnicornException(message); - } - } - } catch (Exception e2) { - Message message = new Message(e2); - throw new UnicornException(message); - } + Message message = new Message(e); + throw new UnicornException(message); } }
Received on Thursday, 17 September 2009 16:54:10 UTC