rwaldhoff    01/08/23 17:23:48

  Modified:    httpclient/src/java/org/apache/commons/httpclient Tag:
                        rlwrefactoring HttpMethod.java HttpMethodBase.java
  Log:
  adding addRequestHeader methods
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.10  +20 -3     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java
  
  Index: HttpMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
  retrieving revision 1.5.2.9
  retrieving revision 1.5.2.10
  diff -u -r1.5.2.9 -r1.5.2.10
  --- HttpMethod.java   2001/08/20 17:21:19     1.5.2.9
  +++ HttpMethod.java   2001/08/24 00:23:48     1.5.2.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
 1.5.2.9 2001/08/20 17:21:19 rwaldhoff Exp $
  - * $Revision: 1.5.2.9 $
  - * $Date: 2001/08/20 17:21:19 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethod.java,v
 1.5.2.10 2001/08/24 00:23:48 rwaldhoff Exp $
  + * $Revision: 1.5.2.10 $
  + * $Date: 2001/08/24 00:23:48 $
    * ====================================================================
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -71,6 +71,23 @@
        * @param header the header
        */
       public void setRequestHeader(Header header);
  +
  +    /**
  +     * Adds the specified request header, NOT overwriting any
  +     * previous value.
  +     * Note that header-name matching is case insensitive.
  +     * @param headerName the header's name
  +     * @param headerValue the header's value
  +     */
  +    public void addRequestHeader(String headerName, String headerValue);
  +
  +    /**
  +     * Adds the specified request header, NOT overwriting any
  +     * previous value.
  +     * Note that header-name matching is case insensitive.
  +     * @param header the header
  +     */
  +    public void addRequestHeader(Header header);
   
       /**
        * Get the request header associated with the given name.
  
  
  
  1.10.2.23 +57 -4     
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.10.2.22
  retrieving revision 1.10.2.23
  diff -u -r1.10.2.22 -r1.10.2.23
  --- HttpMethodBase.java       2001/08/23 21:45:33     1.10.2.22
  +++ HttpMethodBase.java       2001/08/24 00:23:48     1.10.2.23
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.10.2.22 2001/08/23 21:45:33 rwaldhoff Exp $
  - * $Revision: 1.10.2.22 $
  - * $Date: 2001/08/23 21:45:33 $
  + * $Header: 
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
 1.10.2.23 2001/08/24 00:23:48 rwaldhoff Exp $
  + * $Revision: 1.10.2.23 $
  + * $Date: 2001/08/24 00:23:48 $
    * ====================================================================
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -61,7 +61,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
    * @author Rodney Waldhoff
  - * @version $Revision: 1.10.2.22 $
  + * @version $Revision: 1.10.2.23 $
    */
   public abstract class HttpMethodBase implements HttpMethod {
   
  @@ -144,6 +144,53 @@
       }
   
       /**
  +     * Add the specified request header, NOT overwriting any
  +     * previous value.
  +     * Note that header-name matching is case insensitive.
  +     * @param headerName the header's name
  +     * @param headerValue the header's value
  +     */
  +    public void addRequestHeader(String headerName, String headerValue) {
  +        // "It must be possible to combine the multiple header fields into
  +        // one "field-name: field-value" pair, without changing the
  +        // semantics of the message, by appending each subsequent field-value
  +        // to the first, each separated by a comma."
  +        //   - HTTP/1.0 (4.3)
  +        Header header = (Header)(requestHeaders.get(headerName.toLowerCase()));
  +        if(null == header) {
  +            header = new Header(headerName, headerValue);
  +        } else {
  +            header.setValue( (null == header.getValue() ? "" : header.getValue()) +
  +                             ", " +
  +                             (null == headerValue ? "" : headerValue));
  +        }
  +        requestHeaders.put(headerName.toLowerCase(),header);
  +    }
  +
  +    /**
  +     * Add the specified request header, NOT overwriting any
  +     * previous value.
  +     * Note that header-name matching is case insensitive.
  +     * @param header the header
  +     */
  +    public void addRequestHeader(Header header) {
  +        // "It must be possible to combine the multiple header fields into
  +        // one "field-name: field-value" pair, without changing the
  +        // semantics of the message, by appending each subsequent field-value
  +        // to the first, each separated by a comma."
  +        //   - HTTP/1.0 (4.3)
  +        Header orig = (Header)(requestHeaders.get(header.getName().toLowerCase()));
  +        if(null == orig) {
  +            orig = header;
  +        } else {
  +            orig.setValue( (null == orig.getValue() ? "" : orig.getValue()) +
  +                           ", " +
  +                           (null == header.getValue() ? "" : header.getValue()));
  +        }
  +        requestHeaders.put(orig.getName().toLowerCase(),orig);
  +    }
  +
  +    /**
        * Get the request header associated with the given name.
        * Note that header-name matching is case insensitive.
        * @param headerName the header name
  @@ -818,6 +865,12 @@
        * @param conn the {@link HttpConnection} to read the response from
        */
       protected void readResponseHeaders(State state, HttpConnection conn) throws 
IOException, HttpException {
  +        // "It must be possible to combine the multiple header fields into
  +        // one "field-name: field-value" pair, without changing the
  +        // semantics of the message, by appending each subsequent field-value
  +        // to the first, each separated by a comma."
  +        //   - HTTP/1.0 (4.3)
  +
           log.debug("HttpMethodBase.readResponseHeaders(State,HttpConnection)");
           responseHeaders.clear();
   
  
  
  

Reply via email to