Author: scottbw
Date: Sat Oct 6 20:19:39 2012
New Revision: 1395166
URL: http://svn.apache.org/viewvc?rev=1395166&view=rev
Log:
Only obtain content-type header for a response when ignoreContentType is set to
false
Modified:
incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java
Modified:
incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java?rev=1395166&r1=1395165&r2=1395166&view=diff
==============================================================================
---
incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java
(original)
+++
incubator/wookie/trunk/parser/java/src/org/apache/wookie/w3c/W3CWidgetFactory.java
Sat Oct 6 20:19:39 2012
@@ -242,8 +242,10 @@ public class W3CWidgetFactory {
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(url.toString());
client.executeMethod(method);
- String type =
method.getResponseHeader("Content-Type").getValue();
- if (!ignoreContentType &&
!type.startsWith(WIDGET_CONTENT_TYPE)) throw new
InvalidContentTypeException("Problem downloading widget: expected a content
type of "+WIDGET_CONTENT_TYPE+" but received:"+type);
+ if (!ignoreContentType){
+ String type =
method.getResponseHeader("Content-Type").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);
FileUtils.writeByteArrayToFile(file,
IOUtils.toByteArray(method.getResponseBodyAsStream()));
method.releaseConnection();