You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by du...@apache.org on 2002/02/01 22:22:09 UTC

cvs commit: xml-soap/java/src/org/apache/soap/transport/http SOAPHTTPConnection.java

duftler     02/02/01 13:22:09

  Modified:    java/src/org/apache/soap/transport/http
                        SOAPHTTPConnection.java
  Log:
  Committed a patch that makes the set-cookie and set-cookie2 header searches
  case-insensitive.
  Submitted by: Warwick Slade (wslade@earthling.net)
  Reviewed by: Matthew J. Duftler (duftler@us.ibm.com)
  
  Revision  Changes    Path
  1.20      +26 -3     xml-soap/java/src/org/apache/soap/transport/http/SOAPHTTPConnection.java
  
  Index: SOAPHTTPConnection.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/transport/http/SOAPHTTPConnection.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- SOAPHTTPConnection.java	28 Jun 2001 20:12:06 -0000	1.19
  +++ SOAPHTTPConnection.java	1 Feb 2002 21:22:09 -0000	1.20
  @@ -309,9 +309,11 @@
           // stripping everything after the ';' (i.e., ignore all cookie attrs).
           // Only update my state iff the header is there .. otherwise
           // leave the current 
  +        // Note: Header is case-insensitive
           String hdr;
  -        
  -        hdr = (String) responseHeaders.get ("Set-Cookie2");
  +
  +        hdr = getHeaderValue (responseHeaders, "Set-Cookie2");
  +
           if (hdr != null) {
             cookieHeader2 = hdr;
             int index = cookieHeader2.indexOf (';');
  @@ -320,7 +322,8 @@
             }
           }
   
  -        hdr = (String) responseHeaders.get ("Set-Cookie");
  +        hdr = getHeaderValue (responseHeaders, "Set-Cookie");
  +
           if (hdr != null) {
             cookieHeader = hdr;
             int index = cookieHeader.indexOf (';');
  @@ -365,5 +368,25 @@
      */
     public SOAPContext getResponseSOAPContext () {
       return responseSOAPContext;
  +  }
  +
  +  /**
  +   * Obtain a header value from the table using a case insensitive search.
  +   *
  +   * @param headers a colletion of headers from the http response
  +   * @param headerName the name of the header to find
  +   * @return the header value or null if not found
  +   */
  +  private static String getHeaderValue (Hashtable headers, String headerName)
  +  {
  +    for (Enumeration enum = headers.keys (); enum.hasMoreElements ();) {
  +      String key = (String) enum.nextElement();
  +
  +      if (key.equalsIgnoreCase (headerName)) {
  +        return (String) headers.get(key);
  +      }
  +    }
  +
  +    return null;
     }
   }