commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morg...@apache.org
Subject cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/validators ResponseHeaderValidator.java
Date Fri, 03 May 2002 23:17:12 GMT
morgand     02/05/03 16:17:12

  Modified:    latka/src/java/org/apache/commons/latka/validators
                        ResponseHeaderValidator.java
  Log:
  multi-header fix
  
  Revision  Changes    Path
  1.7       +25 -5     jakarta-commons/latka/src/java/org/apache/commons/latka/validators/Attic/ResponseHeaderValidator.java
  
  Index: ResponseHeaderValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/validators/Attic/ResponseHeaderValidator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ResponseHeaderValidator.java	2 May 2002 22:25:44 -0000	1.6
  +++ ResponseHeaderValidator.java	3 May 2002 23:17:12 -0000	1.7
  @@ -59,14 +59,21 @@
   
   package org.apache.commons.latka.validators;
   
  +import java.util.StringTokenizer;
  +
   import org.apache.commons.latka.Validator;
   import org.apache.commons.latka.ValidationException;
   
   import org.apache.commons.latka.http.Response;
   
   /**
  - * ResponseHeaderValidator validates response headers in an HTTP session.
  - *
  + * ResponseHeaderValidator validates response headers in 
  + * an HTTP session.  Setting just the header name tests
  + * for the existence of a header.  If you set the 
  + * headerValue and there is more than one header of that
  + * name, the validator matches on ANY header with that 
  + * value.
  + * 
    * @author Morgan Delagrange
    */
   public class ResponseHeaderValidator extends BaseConditionalValidator {
  @@ -161,11 +168,24 @@
               return true;
           }
   
  -        if (!_actualValue.equals(_headerValue)) {
  -            return false;
  +        // check the entire value against the actual value
  +        if (_actualValue.equals(_headerValue)) {
  +            return true;
  +        }
  +
  +        // if it does not match, see if the header has multiple values
  +        if (_actualValue.indexOf(",") != -1) {
  +            StringTokenizer tokenizer = new StringTokenizer(_actualValue,",");
  +            while (tokenizer.hasMoreTokens()) {
  +                String token = tokenizer.nextToken().trim();
  +                if (token.equals(_headerValue)) {
  +                    return true;
  +                }
  +            }
  +
           }
   
  -        return true;
  +        return false;
       }
   
       public String generateBareExceptionMessage() {
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message