Author: psharples
Date: Tue Jan 15 18:45:52 2013
New Revision: 1433577

URL: http://svn.apache.org/viewvc?rev=1433577&view=rev
Log:
Minor bug fix - missing content-type header for a downloaded widget caused a 
NPE.  Now throws a more obvious exception message when content-type is not 
present.

Modified:
    wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java

Modified: 
wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java
URL: 
http://svn.apache.org/viewvc/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java?rev=1433577&r1=1433576&r2=1433577&view=diff
==============================================================================
--- wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java 
(original)
+++ wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java 
Tue Jan 15 18:45:52 2013
@@ -19,6 +19,7 @@ import java.io.IOException;
 import java.net.URL;
 
 import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.methods.GetMethod;
@@ -243,7 +244,9 @@ public class W3CWidgetFactory {
                GetMethod method = new GetMethod(url.toString());
                client.executeMethod(method);
                if (!ignoreContentType){
-                       String type = 
method.getResponseHeader("Content-Type").getValue();
+                   Header header = method.getResponseHeader("Content-Type");
+                   if (header == null) throw new 
InvalidContentTypeException("Problem downloading widget: expected a content 
type of "+WIDGET_CONTENT_TYPE+" but received no content type description.");
+                       String type = header.getValue();
                        if (!type.startsWith(WIDGET_CONTENT_TYPE)) throw new 
InvalidContentTypeException("Problem downloading widget: expected a content 
type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
                }
                File file = File.createTempFile("wookie", null);


Reply via email to