Browse files

Do not set the response content-length in the NoDecorator, as it is i…

…mpossible to know the content-length in bytes when we don't know the encoding (sitemesh 2.4 used to assume UTF-8, but setting the content-length is not a significant advantage anyway).

Therefore, remove all references to content-length as it is only used by NoDecorator.

(Fixes bug JRADEV-6607)
  • Loading branch information...
1 parent 2ec48b2 commit 4fcde51c60dfa43b60884291cb68e70851255b94 @spudbean spudbean committed Jul 13, 2011
View
2 .gitignore
@@ -1,6 +1,8 @@
build
+target
out
*.iml
*.ipr
*.iws
+.idea
dist
View
2 build.properties
@@ -18,4 +18,4 @@ compile.nowarn = off
Name = OpenSymphony SiteMesh
name = sitemesh
-version = 2.5-atlassian-2
+version = 2.5-atlassian-3
View
3 pom.xml
@@ -4,14 +4,15 @@
<modelVersion>4.0.0</modelVersion>
<!--
+ ant clean test
ant clean jar sources
mvn deploy:deploy-file -Dfile=./dist/sitemesh-2.5-atlassian-2.jar -DpomFile=./pom.xml -Durl=https://maven.atlassian.com/public -DrepositoryId=atlassian-public
mvn deploy:deploy-file -Dfile=./dist/sitemesh-2.5-atlassian-2-sources.jar -DpomFile=./pom.xml -Dclassifier=sources -Durl=https://maven.atlassian.com/public -DrepositoryId=atlassian-public
-->
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
- <version>2.5-atlassian-2</version>
+ <version>2.5-atlassian-3</version>
<packaging>jar</packaging>
<name>SiteMesh</name>
View
8 src/java/com/opensymphony/module/sitemesh/Page.java
@@ -68,14 +68,6 @@
String getTitle();
/**
- * Length of the <code>Page</code>, in the format before
- * it was parsed.
- *
- * @return Length of page data (in number of bytes).
- */
- int getContentLength();
-
- /**
* Get a property embedded into the <code>Page</code> as a <code>String</code>.
*
* @param name Name of property
View
27 src/java/com/opensymphony/module/sitemesh/parser/AbstractPage.java
@@ -83,21 +83,6 @@ public String getTitle() {
return noNull(getProperty("title"));
}
- public int getContentLength() {
- // We encode it but not into a new buffer
- CountingOutputStream counter = new CountingOutputStream();
- try
- {
- OutputStreamWriter writer = new OutputStreamWriter(counter);
- writePage(writer);
- // We must flush, because the writer will buffer
- writer.flush();
- } catch (IOException ioe) {
- // Ignore, it's not possible with our OutputStream
- }
- return counter.getCount();
- }
-
public String getProperty(String name) {
if (!isPropertySet(name)) return null;
return (String)properties.get(name);
@@ -180,18 +165,6 @@ protected static String noNull(String in) {
return in == null ? "" : in;
}
- private static class CountingOutputStream extends OutputStream {
- private int count = 0;
-
- @Override
- public void write(int i) throws IOException {
- count++;
- }
-
- public int getCount() {
- return count;
- }
- }
}
class PageRequest extends HttpServletRequestWrapper {
View
6 src/java/com/opensymphony/sitemesh/Content.java
@@ -15,12 +15,6 @@
void writeOriginal(Writer writer) throws IOException;
/**
- * Length of the original unprocessed content.
- */
- int originalLength();
-
-
- /**
* Write the contents of the <code>&lt;body&gt;</code> tag.
*/
void writeBody(Writer out) throws IOException;
View
4 src/java/com/opensymphony/sitemesh/compatability/Content2HTMLPage.java
@@ -72,10 +72,6 @@ public String getTitle() {
return content.getTitle();
}
- public int getContentLength() {
- return content.originalLength();
- }
-
public String getProperty(String name) {
return content.getProperty(name);
}
View
4 src/java/com/opensymphony/sitemesh/compatability/HTMLPage2Content.java
@@ -23,10 +23,6 @@ public void writeOriginal(Writer out) throws IOException {
page.writePage(out);
}
- public int originalLength() {
- return page.getContentLength();
- }
-
public void writeBody(Writer out) throws IOException {
page.writeBody(out);
}
View
2 src/java/com/opensymphony/sitemesh/webapp/decorator/NoDecorator.java
@@ -22,8 +22,6 @@ protected void render(Content content, HttpServletRequest request, HttpServletRe
ServletContext servletContext, SiteMeshWebAppContext webAppContext)
throws IOException, ServletException {
- response.setContentLength(content.originalLength());
-
if (webAppContext.isUsingStream()) {
PrintWriter writer = new PrintWriter(response.getOutputStream());
content.writeOriginal(writer);
View
1 src/test/com/opensymphony/module/sitemesh/parser/HTMLPageParserTest.java
@@ -150,7 +150,6 @@ public void testContentSanity() throws Exception {
Page bigPage = parser.parse(new DefaultSitemeshBuffer(bigChars, chars.length));
assertEquals(bigPage.getPage(), page.getPage());
- assertEquals(bigPage.getContentLength(), page.getContentLength());
}
private String join(String[] values) {

0 comments on commit 4fcde51

Please sign in to comment.