tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remy Maucherat <r...@apache.org>
Subject Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/http MimeHeaders.java
Date Fri, 25 Mar 2005 10:41:16 GMT
billbarker@apache.org wrote:
> billbarker    2005/03/24 19:53:25
> 
>   Modified:    util/java/org/apache/tomcat/util/http MimeHeaders.java
>   Log:
>   Make setValue guarantee that the header is unique (that's how it's being used anyway).
>   
>   Fix for Bug #34113

>   - 	MessageBytes value=getValue(name);
>   -	if( value == null ) {
>   -	    MimeHeaderField mh = createHeader();
>   -	    mh.getName().setString(name);
>   -	    value=mh.getValue();
>   -	}
>   -	return value;
>   +        for ( int i = 0; i < count; i++ ) {
>   +            if(headers[i].getName().equalsIgnoreCase(name)) {
>   +                for ( int j=i+1; j < count; j++ ) {
>   +                    if(headers[j].getName().equalsIgnoreCase(name)) {
>   +                        removeHeader(j--);
>   +                    }
>   +                }
>   +                return headers[i].getValue();
>   +            }
>   +        }
>   +        MimeHeaderField mh = createHeader();
>   +        mh.getName().setString(name);
>   +        return mh.getValue();

This should be more efficient as I don't like what removeHeader does. 
Since it only happens when actually having a multi valued header, it is 
not that critical, however.

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message