Author: markt
Date: Tue Jan 10 15:06:22 2006
New Revision: 367826
URL: http://svn.apache.org/viewcvs?rev=367826&view=rev
Log:
Alternative patch for bug 29214 based on Remy's comments
Modified:
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Response.java
tomcat/container/tc5.5.x/webapps/docs/changelog.xml
Modified:
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Response.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Response.java?rev=367826&r1=367825&r2=367826&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Response.java
(original)
+++
tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/connector/Response.java
Tue Jan 10 15:06:22 2006
@@ -219,9 +219,9 @@
private boolean isCharacterEncodingSet = false;
/**
- * The contextType flag
+ * The contentLength flag
*/
- private boolean isContentTypeSet = false;
+ private boolean isContentLengthSet = false;
/**
@@ -275,7 +275,7 @@
appCommitted = false;
included = false;
error = false;
- isContentTypeSet = false;
+ isContentLengthSet = false;
isCharacterEncodingSet = false;
cookies.clear();
@@ -651,6 +651,7 @@
coyoteResponse.reset();
outputBuffer.reset();
+ isContentLengthSet = false;
}
@@ -708,6 +709,8 @@
return;
coyoteResponse.setContentLength(length);
+
+ isContentLengthSet = true;
}
@@ -744,7 +747,8 @@
if (index != -1) {
int len = type.length();
index++;
- while (index < len && Character.isSpace(type.charAt(index))) {
+ while (index < len
+ && Character.isWhitespace(type.charAt(index))) {
index++;
}
if (index+7 < len
@@ -760,8 +764,6 @@
}
}
}
-
- isContentTypeSet = true;
}
@@ -1011,6 +1013,12 @@
coyoteResponse.addHeader(name, value);
+ char cc=name.charAt(0);
+ if(cc=='C' || cc=='c') {
+ if(name.equalsIgnoreCase("Content-Length")) {
+ isContentLengthSet = true;
+ }
+ }
}
@@ -1040,6 +1048,20 @@
* @param name Name of the header to check
*/
public boolean containsHeader(String name) {
+ // Need special handling for Content-Type and Content-Length due to
+ // special handling of these in coyoteResponse
+ char cc=name.charAt(0);
+ if(cc=='C' || cc=='c') {
+ if(name.equalsIgnoreCase("Content-Type")) {
+ // Will return null if this has not been set
+ return (coyoteResponse.getContentType() != null);
+ }
+ if(name.equalsIgnoreCase("Content-Length")) {
+ // Can't use null test since this header is an int
+ return isContentLengthSet;
+ }
+ }
+
return coyoteResponse.containsHeader(name);
}
@@ -1268,6 +1290,13 @@
return;
coyoteResponse.setHeader(name, value);
+
+ char cc=name.charAt(0);
+ if(cc=='C' || cc=='c') {
+ if(name.equalsIgnoreCase("Content-Length")) {
+ isContentLengthSet = true;
+ }
+ }
}
Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=367826&r1=367825&r2=367826&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Tue Jan 10 15:06:22 2006
@@ -25,11 +25,16 @@
<subsection name="Catalina">
<changelog>
<fix>
- <bug>23950</bug>: Context.listBindings() should return objects not
references. (markt)
+ <bug>23950</bug>: Context.listBindings() should return objects not
+ references. (markt)
</fix>
<fix>
<bug>38124</bug>: Add support for Windows 20xx when reading environment
variables in CGIServlet. (markt)
+ </fix>
+ <fix>
+ <bug>29214</bug>: response.containsHeader() now returns the correct
+ value for Content-Type and Content-Length headers. (markt)
</fix>
</changelog>
</subsection>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]