Author: mir
Date: Mon Jan 18 18:51:26 2010
New Revision: 900509
URL: http://svn.apache.org/viewvc?rev=900509&view=rev
Log:
CLEREZZA-69: content length header now only set if not isHtml
Modified:
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedRequest.java
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlFilter.java
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlSettingBody.java
Modified:
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedRequest.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedRequest.java?rev=900509&r1=900508&r2=900509&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedRequest.java
(original)
+++
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedRequest.java
Mon Jan 18 18:51:26 2010
@@ -19,13 +19,10 @@
package org.apache.clerezza.platform.xhtml2html;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.wymiwyg.wrhapi.HandlerException;
import org.wymiwyg.wrhapi.HeaderName;
import org.wymiwyg.wrhapi.Request;
-import org.wymiwyg.wrhapi.util.AcceptHeaderEntry;
-import org.wymiwyg.wrhapi.util.AcceptHeaderIterator;
import org.wymiwyg.wrhapi.util.RequestWrapper;
/**
Modified:
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java?rev=900509&r1=900508&r2=900509&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java
(original)
+++
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java
Mon Jan 18 18:51:26 2010
@@ -18,6 +18,8 @@
*/
package org.apache.clerezza.platform.xhtml2html;
+import java.util.ArrayList;
+import java.util.List;
import org.wymiwyg.wrhapi.HandlerException;
import org.wymiwyg.wrhapi.HeaderName;
import org.wymiwyg.wrhapi.MessageBody;
@@ -32,6 +34,7 @@
private String XHTML_TYPE = "application/xhtml+xml";
private String HTML_TYPE = "text/html";
private boolean isHtml = false;
+ private List<Object> contentLengths = new ArrayList<Object>();
public WrappedResponse(Response response) {
super(response);
@@ -41,13 +44,17 @@
@Override
public void addHeader(HeaderName headerName, Object value) throws
HandlerException {
- if (headerName.equals(HeaderName.CONTENT_LENGTH) && isHtml) {
+ if (headerName.equals(HeaderName.CONTENT_LENGTH)) {
+ if (isHtml) {
+ // do nothing
+ } else {
+ contentLengths.add(value);
+ }
return;
}
if (headerName.equals(HeaderName.CONTENT_TYPE) &&
XHTML_TYPE.equals(value)) {
super.addHeader(headerName, HTML_TYPE);
isHtml = true;
- super.setHeader(HeaderName.CONTENT_LENGTH, null);
} else {
super.addHeader(headerName, value);
}
@@ -55,13 +62,18 @@
@Override
public void setHeader(HeaderName headerName, Object value) throws
HandlerException {
- if (headerName.equals(HeaderName.CONTENT_LENGTH) && isHtml) {
+ if (headerName.equals(HeaderName.CONTENT_LENGTH)) {
+ if (isHtml) {
+ // do nothing
+ } else {
+ contentLengths.clear();
+ contentLengths.add(value);
+ }
return;
}
if (headerName.equals(HeaderName.CONTENT_TYPE) &&
XHTML_TYPE.equals(value)) {
super.setHeader(headerName, HTML_TYPE);
isHtml = true;
- super.setHeader(HeaderName.CONTENT_LENGTH, null);
} else {
super.setHeader(headerName, value);
}
@@ -76,4 +88,10 @@
public boolean isHtml() {
return isHtml;
}
+
+ void setContentLengthIfNotHtml() throws HandlerException {
+ if (contentLengths.size() > 0 && !isHtml) {
+ super.setHeader(HeaderName.CONTENT_LENGTH,
contentLengths.toArray());
+ }
+ }
}
Modified:
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlFilter.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlFilter.java?rev=900509&r1=900508&r2=900509&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlFilter.java
(original)
+++
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlFilter.java
Mon Jan 18 18:51:26 2010
@@ -51,7 +51,9 @@
if (!isApplicable(request)) {
handler.handle(request, response);
} else {
- handler.handle(new WrappedRequest(request), new
WrappedResponse(response));
+ WrappedResponse wrappedResponse = new
WrappedResponse(response);
+ handler.handle(new WrappedRequest(request),
wrappedResponse);
+ wrappedResponse.setContentLengthIfNotHtml();
}
}
Modified:
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlSettingBody.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlSettingBody.java?rev=900509&r1=900508&r2=900509&view=diff
==============================================================================
---
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlSettingBody.java
(original)
+++
incubator/clerezza/issues/CLEREZZA-69/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/Xhtml2HtmlSettingBody.java
Mon Jan 18 18:51:26 2010
@@ -45,6 +45,4 @@
new SelfClosing2ClosingTagsByteChannel(
byteChannel, wrappedResponse),
wrappedResponse));
}
-
-
}