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/http Request.java RequestImpl.java Session.java SessionImpl.java
Date Tue, 16 Jul 2002 22:57:30 GMT
morgand     2002/07/16 15:57:30

  Modified:    latka/src/java/org/apache/commons/latka/http Request.java
                        RequestImpl.java Session.java SessionImpl.java
  Log:
  adding HTTP/1.0 support - patch submitted by Ryan Lubke
  
  Revision  Changes    Path
  1.16      +9 -0      jakarta-commons/latka/src/java/org/apache/commons/latka/http/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/Request.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Request.java	15 Jul 2002 16:10:26 -0000	1.15
  +++ Request.java	16 Jul 2002 22:57:29 -0000	1.16
  @@ -209,4 +209,13 @@
        */
       void setRequestBody(String body);
   
  +    /**
  +     * Sets the version of HTTP that is used in the request.
  +     * If the version of HTTP specified is not 1.0 or 1.1,
  +     * then the default of 1.1 will be used.
  +     *
  +     * @param version  HTTP version.
  +     */
  +    void setVersion(String version);
  +
   }
  
  
  
  1.25      +20 -1     jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java
  
  Index: RequestImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/RequestImpl.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- RequestImpl.java	15 Jul 2002 16:10:26 -0000	1.24
  +++ RequestImpl.java	16 Jul 2002 22:57:30 -0000	1.25
  @@ -70,6 +70,7 @@
   import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.HttpMethod;
   import org.apache.commons.httpclient.HttpState;
  +import org.apache.commons.httpclient.HttpMethodBase;
   import org.apache.commons.httpclient.methods.GetMethod;
   import org.apache.commons.httpclient.methods.HeadMethod;
   import org.apache.commons.httpclient.methods.PostMethod;
  @@ -128,6 +129,12 @@
       protected static final Category _log = 
           Category.getInstance(RequestImpl.class);
       
  +
  +    /**
  +     * HTTP Version 1.0
  +     */
  +    private static final String HTTP_10 = "1.0";
  +
       /**
        * Create a request for the specified URL, process using the supplied method
        * and use the supplied state and session for persistent data
  @@ -513,4 +520,16 @@
           _proxy = proxy;
       }
       
  +    /**
  +     * Sets the HTTP version for this request.  If
  +     * the version provided is not 1.0 or 1.1, then
  +     * 1.1 will be used.
  +     *
  +     * @param version  HTTP version
  +     */
  +    public void setVersion(String version) {
  +        if (version.equals(HTTP_10)) {
  +            ((HttpMethodBase) _httpMethod).setHttp11(false);
  +        }
  +    }
   }
  
  
  
  1.11      +23 -13    jakarta-commons/latka/src/java/org/apache/commons/latka/http/Session.java
  
  Index: Session.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/Session.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Session.java	4 Jul 2002 14:06:32 -0000	1.10
  +++ Session.java	16 Jul 2002 22:57:30 -0000	1.11
  @@ -75,25 +75,31 @@
   public interface Session {
   
       /**
  -     * Creates a request object with the specified URL and HTTP Method.
  +     * Creates a request object with the specified URL, HTTP Method,
  +     * and version.
        * 
        * @param url        The URL to request of the HTTP server.
        * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
        *      used to communicate with server.
  +     * @param version A String representing the version of the HTTP request, i.e.
  +     *      1.0 or 1.1.
        * @return a new {@link Request} object representing the <code>url</code>
        *      and <code>httpMethod</code>
        * @see org.apache.commons.latka.http.Request#HTTP_METHOD_GET
        * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST
        */
  -    Request createRequest(URL url, int httpMethod);
  +    Request createRequest(URL url, int httpMethod, String version);
       
  -    /** Create a request with the given label, to access the given URL via the
  -     * given HTTP method, and follow redirects as specified.
  +    /** 
  +     * Creates a labeled request object, with the specified URL, HTTP Method,
  +     * version, and redirect handling behavior.
        *
        * @param label a name used to identify the request
        * @param url The URL to request of the HTTP server.
        * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
        *      used to communicate with server.
  +     * @param version A String representing the version of the HTTP request, i.e.
  +     *      1.0 or 1.1.
        * @param followRedirects whether to follow HTTP redirection responses
        * @return a new {@link Request} object representing the <code>url</code>
        *      and <code>httpMethod</code>
  @@ -101,32 +107,36 @@
        * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST
        */
       Request createRequest(String label, URL url, int httpMethod,
  -        boolean followRedirects);
  +        String version, boolean followRedirects);
   
       /**
  -     * Creates a request object with the specified URL and HTTP Method to be
  -     * accessed via the provided proxy
  +     * Creates a request object with the specified URL, HTTP Method, and 
  +     * version to be accessed via the provided proxy.
        * 
        * @param url The URL to request of the HTTP server.
        * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
        *      used to communicate with server.
        * @param proxy a proxy to use during the request
  +     * @param version A String representing the version of the HTTP request, i.e.
  +     *      1.0 or 1.1.
        * @return a new {@link Request} object representing the <code>url</code>
        *      and <code>httpMethod</code>.
        * @see org.apache.commons.latka.http.Request#HTTP_METHOD_GET
        * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST
        * @see org.apache.commons.latka.http.Proxy
        */
  -    Request createRequest(URL url, int httpMethod, Proxy proxy);
  +    Request createRequest(URL url, int httpMethod, Proxy proxy, String version);
   
  -    /** Create a request with the given label, to access the given URL via the
  -     * given HTTP method, and follow redirects as specified, using the given
  -     * proxy for communications
  +    /** 
  +     * Create a labeled request with the specified URL, HTTP method, version, and
  +     * redirect handling behavior, using the given proxy for communication.
        *
        * @param label a name used to identify the request
        * @param url The URL to request of the HTTP server.
        * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
        *    used to communicate with server.
  +     * @param version A String representing the version of the HTTP request, i.e.
  +     *      1.0 or 1.1.
        * @param followRedirects whether to follow HTTP redirection responses
        * @param proxy a proxy to use during the request
        * @return a new {@link Request} object representing the <code>url</code>

  @@ -136,7 +146,7 @@
        * @see org.apache.commons.latka.http.Proxy
        */
       Request createRequest(String label, URL url, int httpMethod,
  -        boolean followRedirects, Proxy proxy);
  +        String version, boolean followRedirects, Proxy proxy);
   
       /**
        * Adds a cookie to all HTTP requests whose domain and path match 
  
  
  
  1.14      +29 -17    jakarta-commons/latka/src/java/org/apache/commons/latka/http/SessionImpl.java
  
  Index: SessionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/http/SessionImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SessionImpl.java	4 Jul 2002 14:06:32 -0000	1.13
  +++ SessionImpl.java	16 Jul 2002 22:57:30 -0000	1.14
  @@ -100,29 +100,36 @@
     ///////////////////////////////
   
     /**
  -   * Creates a request object with the specified URL and HTTP Method.
  -   * 
  +   * Creates a request object with the specified URL, HTTP Method,
  +   * and version.
  +   *
      * @param url        The URL to request of the HTTP server.
      * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
      *        used to communicate with server.
  +   * @param version A String representing the version of the HTTP request, i.e.
  +   *        1.0 or 1.1.
      * @return a new <code>Request</code> object representing the <code>url</code>
      *        and <code>httpMethod</code>
      * @see org.apache.commons.latka.http.Request#HTTP_METHOD_GET
      * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST
      */
  -  public Request createRequest(URL url, int httpMethod) {
  +  public Request createRequest(URL url, int httpMethod, String version) {
           // default label to null, follow redirects to true and proxy to null
  -        return createRequest(null, url, httpMethod, true, null);
  +        return createRequest(null, url, httpMethod, version, true, null);
     }
   
     /**
  -   * Creates a request object with the specified URL and HTTP Method.  Note:
  -   * in the current implementation, old request objects will not 
  +   * Creates a labeled request object with the specified URL, HTTP Method, 
  +   * version, and redirect handling behavior.
  +   *
  +   * Note: in the current implementation, old request objects will not be resued. 
      * 
      * @param label  Name of the request
      * @param url        The URL to request of the HTTP server.
      * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
      *        used to communicate with server.
  +   * @param version A String representing the version of the HTTP request, i.e.
  +   *        1.0 or 1.1.
      * @param followRedirects whether HTTP redirects should be processed
      * @return a new <code>Request</code> object representing the <code>url</code>
      *        and <code>httpMethod</code>
  @@ -130,18 +137,20 @@
      * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST
      */
     public Request createRequest(String label, URL url, int httpMethod, 
  -    boolean followRedirects) {
  +    String version, boolean followRedirects) {
         // default proxy to null
  -      return createRequest(label, url, httpMethod, followRedirects, null);
  +      return createRequest(label, url, httpMethod, version, followRedirects, null);
     }
   
       /**
  -     * Creates a request object with the specified URL and HTTP Method to be
  -     * accessed via the provided proxy
  +     * Creates a request object with the specified URL, HTTP Method, and
  +     * version to be accessed via the provided proxy.
        * 
        * @param url        The URL to request of the HTTP server.
        * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
        *      used to communicate with server.
  +     * @param version A String representing the version of the HTTP request, i.e.
  +     *      1.0 or 1.1.
        * @return a new {@link Request} object representing the <code>url</code>
        *      and <code>httpMethod</code>
        * @param proxy a proxy to use during the request
  @@ -149,19 +158,21 @@
        * @see org.apache.commons.latka.http.Request#HTTP_METHOD_POST
        * @see org.apache.commons.latka.http.Proxy
        */
  -    public Request createRequest(URL url, int httpMethod, Proxy proxy) {
  +    public Request createRequest(URL url, int httpMethod, Proxy proxy, String version)
{
           // default label to null, and follow redirects to true
  -        return createRequest(null, url, httpMethod, true, proxy);
  +        return createRequest(null, url, httpMethod, version, true, proxy);
       }
   
  -    /** Create a request with the given label, to access the given URL via the
  -     * given HTTP method, and follow redirects as specified, using the given
  -     * proxy for communications
  +    /** 
  +     * Create a labeled request , with the specified URL, HTTP method, version, and 
  +     * redirect handling behavior, using the given proxy for communications.
        *
        * @param label a name used to identify the request
        * @param url The URL to request of the HTTP server.
        * @param httpMethod An integer representing the HTTP method (e.g. GET, PUT)
        *      used to communicate with server.
  +     * @param version A String representing the version of the HTTP request, i.e.
  +     *      1.0 or 1.1.
        * @param followRedirects whether to follow HTTP redirection responses
        * @param proxy a proxy to use during the request
        * @return a new {@link Request} object representing the <code>url</code>
  @@ -171,11 +182,12 @@
        * @see org.apache.commons.latka.http.Proxy
        */
       public Request createRequest(String label, URL url, int httpMethod,
  -        boolean followRedirects, Proxy proxy) {
  +        String version, boolean followRedirects, Proxy proxy) {
       
           RequestImpl request = new RequestImpl(label, url, httpMethod, _state, 
               this, followRedirects);
           request.setProxy(proxy);
  +        request.setVersion(version);
   
           URL referer = getReferer();
   
  
  
  

--
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