Re: svn commit: r367115 - /tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java
[EMAIL PROTECTED] wrote: Author: markt Date: Sun Jan 8 14:48:43 2006 New Revision: 367115 URL: http://svn.apache.org/viewcvs?rev=367115view=rev Log: Fix bug 29214. containsHeader() not working for Content-Length and Content-Type I don't like this fix (to a non issue), but since I have the opportunity of not using it, you can leave it in if you want to. Rather than adding complexity in code which is critical, I would have hacked instead the org.apache.catalina.connector.Response.containsHeader method, which is not actually used at all (except by application code, IMO for weird reasons). Rémy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: svn commit: r367115 - /tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java
Remy Maucherat wrote: [EMAIL PROTECTED] wrote: Fix bug 29214. containsHeader() not working for Content-Length and Content-Type Rather than adding complexity in code which is critical, I would have hacked instead the org.apache.catalina.connector.Response.containsHeader method, which is not actually used at all (except by application code, IMO for weird reasons). I'll look into an alternative patch that has less impact on the critical code. Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: svn commit: r367115 - /tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java
If you're looking to reduce complexity - one idea would be to check if the redundant fields are actually needed, because that's the actual source of the problem. I can only think of performance benefits - storing the contentLength as an int may be a good way to avoid conversion to and from String - but the headers are stored as MessageBytes, and that supports storing the int value. If the redundant values are used to avoid looking up the header - storing the MessageBytes value could solve this. If you decide to fix it at the higher layer - maybe you can also deprecate the method containsHeader in Response or put a big javadoc saying that it's not very accurate. Costin On 1/9/06, Mark Thomas [EMAIL PROTECTED] wrote: Remy Maucherat wrote: [EMAIL PROTECTED] wrote: Fix bug 29214. containsHeader() not working for Content-Length and Content-Type Rather than adding complexity in code which is critical, I would have hacked instead the org.apache.catalina.connector.Response.containsHeader method, which is not actually used at all (except by application code, IMO for weird reasons). I'll look into an alternative patch that has less impact on the critical code. Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
svn commit: r367115 - /tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java
Author: markt Date: Sun Jan 8 14:48:43 2006 New Revision: 367115 URL: http://svn.apache.org/viewcvs?rev=367115view=rev Log: Fix bug 29214. containsHeader() not working for Content-Length and Content-Type Modified: tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java Modified: tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java URL: http://svn.apache.org/viewcvs/tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java?rev=367115r1=367114r2=367115view=diff == --- tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java (original) +++ tomcat/connectors/trunk/coyote/src/java/org/apache/coyote/Response.java Sun Jan 8 14:48:43 2006 @@ -117,6 +117,16 @@ protected boolean charsetSet = false; /** + * Has the content length been explicitly set. + */ +protected boolean contentLengthSet = false; + +/** + * Has the content type been explicitly set. + */ +protected boolean contentTypeSet = false; + +/** * Request error URI. */ protected String errorURI = null; @@ -276,12 +286,15 @@ // Reset the headers only if this is the main request, // not for included -contentType = null;; +contentType = null; locale = DEFAULT_LOCALE; contentLanguage = null; characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; contentLength = -1; charsetSet = false; +contentTypeSet = false; +contentLengthSet = false; + status = 200; message = null; @@ -312,6 +325,14 @@ // Headers public boolean containsHeader(String name) { +char cc=name.charAt(0); +if(cc=='C' || cc=='c') { +if(name.equalsIgnoreCase(Content-Type)) { +return contentTypeSet; +} else if(name.equalsIgnoreCase(Content-Length)) { +return contentLengthSet; +} +} return headers.getHeader(name) != null; } @@ -361,6 +382,7 @@ } if( name.equalsIgnoreCase( Content-Language ) ) { // XXX XXX Need to construct Locale or something else +// Needs special handling in containsHeader() as well } return false; } @@ -454,9 +476,12 @@ if (type == null) { this.contentType = null; +contentTypeSet = false; return; } +contentTypeSet = true; + /* * Remove the charset param (if any) from the Content-Type, and use it * to set the response encoding. @@ -469,7 +494,7 @@ while (index != -1) { semicolonIndex = index; index++; -while (index len Character.isSpace(type.charAt(index))) { +while (index len Character.isWhitespace(type.charAt(index))) { index++; } if (index+8 len @@ -526,10 +551,12 @@ public void setContentLength(int contentLength) { this.contentLength = contentLength; +contentLengthSet = true; } public void setContentLength(long contentLength) { this.contentLength = contentLength; +contentLengthSet = true; } public int getContentLength() { @@ -565,6 +592,8 @@ locale = DEFAULT_LOCALE; characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING; charsetSet = false; +contentLengthSet = false; +contentTypeSet = false; contentLength = -1; status = 200; message = null; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]