You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2003/01/04 15:17:13 UTC

cvs commit: jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http SessionTag.java BodyTag.java DeleteTag.java GetTag.java HttpTagSupport.java HeadTag.java OptionsTag.java PostTag.java PutTag.java MethodSupportTag.java

dion        2003/01/04 06:17:13

  Modified:    jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http
                        SessionTag.java BodyTag.java DeleteTag.java
                        GetTag.java HttpTagSupport.java HeadTag.java
                        OptionsTag.java PostTag.java PutTag.java
  Removed:     jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http
                        MethodSupportTag.java
  Log:
  Coded to latest HttpClient spec
  
  Revision  Changes    Path
  1.3       +7 -6      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/SessionTag.java
  
  Index: SessionTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/SessionTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionTag.java	23 Oct 2002 16:35:35 -0000	1.2
  +++ SessionTag.java	4 Jan 2003 14:17:13 -0000	1.3
  @@ -61,7 +61,7 @@
   
   package org.apache.commons.jelly.tags.http;
   
  -import org.apache.commons.httpclient.HttpMultiClient;
  +import org.apache.commons.httpclient.HttpClient;
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
   
  @@ -86,7 +86,7 @@
       private boolean _strictMode = false;
       
       /** http client used to store state and execute requests */
  -    private HttpMultiClient _httpClient;
  +    private HttpClient _httpClient;
       
       /** 
        * Creates a new instance of SessionTag
  @@ -102,9 +102,10 @@
        */
       public void doTag(XMLOutput xmlOutput) throws Exception {
           if (isProxyAvailable()) {
  -            _httpClient = new HttpMultiClient(getProxyHost(), getProxyPort());
  +            _httpClient = new HttpClient();
  +            _httpClient.getHostConfiguration().setProxy(getProxyHost(), getProxyPort());
           } else {
  -            _httpClient = new HttpMultiClient();
  +            _httpClient = new HttpClient();
           }
           
           invokeBody(xmlOutput);
  @@ -115,7 +116,7 @@
        *
        * @return Value of property httpClient.
        */
  -    public HttpMultiClient getHttpClient() {
  +    public HttpClient getHttpClient() {
           return _httpClient;
       }
       
  @@ -124,7 +125,7 @@
        *
        * @param httpClient New value of property httpClient.
        */
  -    public void setHttpClient(HttpMultiClient httpClient) {
  +    public void setHttpClient(HttpClient httpClient) {
           _httpClient = httpClient;
       }
       /**
  
  
  
  1.3       +8 -8      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/BodyTag.java
  
  Index: BodyTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/BodyTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BodyTag.java	23 Oct 2002 16:35:35 -0000	1.2
  +++ BodyTag.java	4 Jan 2003 14:17:13 -0000	1.3
  @@ -61,9 +61,9 @@
   
   package org.apache.commons.jelly.tags.http;
   
  -import org.apache.commons.httpclient.HttpUrlMethod;
  -import org.apache.commons.httpclient.methods.UrlPostMethod;
  -import org.apache.commons.httpclient.methods.UrlPutMethod;
  +import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.methods.PostMethod;
  +import org.apache.commons.httpclient.methods.PutMethod;
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
   
  @@ -90,13 +90,13 @@
       public void doTag(XMLOutput xmlOutput) throws Exception {
           HttpTagSupport httpTag = (HttpTagSupport) findAncestorWithClass(
               HttpTagSupport.class);
  -        HttpUrlMethod httpMethod = httpTag.getHttpUrlMethod();
  +        HttpMethod httpMethod = httpTag.getHttpMethod();
           String bodyText = getBodyText();
  -        if (httpMethod instanceof UrlPostMethod) {
  -            UrlPostMethod postMethod = (UrlPostMethod) httpMethod;
  +        if (httpMethod instanceof PostMethod) {
  +            PostMethod postMethod = (PostMethod) httpMethod;
               postMethod.setRequestBody(bodyText);
  -        } else if (httpMethod instanceof UrlPutMethod) {
  -            UrlPutMethod putMethod = (UrlPutMethod) httpMethod;
  +        } else if (httpMethod instanceof PutMethod) {
  +            PutMethod putMethod = (PutMethod) httpMethod;
               putMethod.setRequestBody(bodyText);
           } else {
               throw new IllegalStateException("Http method from parent was "
  
  
  
  1.4       +5 -5      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/DeleteTag.java
  
  Index: DeleteTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/DeleteTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DeleteTag.java	23 Oct 2002 16:35:35 -0000	1.3
  +++ DeleteTag.java	4 Jan 2003 14:17:13 -0000	1.4
  @@ -63,8 +63,8 @@
   
   import java.net.MalformedURLException;
   
  -import org.apache.commons.httpclient.HttpUrlMethod;
  -import org.apache.commons.httpclient.methods.UrlDeleteMethod;
  +import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.methods.DeleteMethod;
   
   /**
    * A http delete tag
  @@ -75,7 +75,7 @@
   public class DeleteTag extends HttpTagSupport {
       
       /** the delete method */
  -    private UrlDeleteMethod _deleteMethod;
  +    private DeleteMethod _deleteMethod;
       
       /**
        * Creates a new instance of DeleteTag
  @@ -87,9 +87,9 @@
        * @return a url method for a get request
        * @throws MalformedURLException when the url is bad
        */
  -    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +    protected HttpMethod getHttpMethod() throws MalformedURLException {
           if (_deleteMethod == null) {
  -            _deleteMethod = new UrlDeleteMethod(getResolvedUrl());
  +            _deleteMethod = new DeleteMethod(getResolvedUrl());
           }
           return _deleteMethod;
       }
  
  
  
  1.4       +5 -5      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/GetTag.java
  
  Index: GetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/GetTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GetTag.java	23 Oct 2002 16:35:35 -0000	1.3
  +++ GetTag.java	4 Jan 2003 14:17:13 -0000	1.4
  @@ -63,8 +63,8 @@
   
   import java.net.MalformedURLException;
   
  -import org.apache.commons.httpclient.HttpUrlMethod;
  -import org.apache.commons.httpclient.methods.UrlGetMethod;
  +import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.methods.GetMethod;
   
   /**
    * A http get tag
  @@ -75,7 +75,7 @@
   public class GetTag extends HttpTagSupport {
       
       /** the get method */
  -    private UrlGetMethod _getMethod;
  +    private GetMethod _getMethod;
       
       /**
        * Creates a new instance of GetTag
  @@ -87,9 +87,9 @@
        * @return a url method for a get request
        * @throws MalformedURLException when the url is bad
        */
  -    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +    protected HttpMethod getHttpMethod() throws MalformedURLException {
           if (_getMethod == null) {
  -            _getMethod = new UrlGetMethod(getResolvedUrl());
  +            _getMethod = new GetMethod(getResolvedUrl());
           }
           return _getMethod;
       }
  
  
  
  1.3       +11 -11    jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/HttpTagSupport.java
  
  Index: HttpTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/HttpTagSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HttpTagSupport.java	23 Oct 2002 16:35:35 -0000	1.2
  +++ HttpTagSupport.java	4 Jan 2003 14:17:13 -0000	1.3
  @@ -65,8 +65,8 @@
   import java.util.ArrayList;
   import java.util.List;
   
  -import org.apache.commons.httpclient.HttpMultiClient;
  -import org.apache.commons.httpclient.HttpUrlMethod;
  +import org.apache.commons.httpclient.HttpClient;
  +import org.apache.commons.httpclient.HttpMethod;
   import org.apache.commons.httpclient.NameValuePair;
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
  @@ -134,13 +134,13 @@
       
       /**
        * A method that must be implemented by subclasses to provide the 
  -     * {@link HttpUrlMethod url method} implementation
  +     * {@link HttpMethod url method} implementation
        *
        * @return a HttpUrlMethod implementation
        * @throws MalformedURLException when the {@link getUrl() url} or 
        * {@link #getPath() path} is invalid
        */
  -    protected abstract HttpUrlMethod getHttpUrlMethod() 
  +    protected abstract HttpMethod getHttpMethod() 
           throws MalformedURLException;
       
       /**
  @@ -153,7 +153,7 @@
       public void doTag(XMLOutput xmlOutput) throws Exception {
           // allow nested tags first, e.g body
           invokeBody(xmlOutput);
  -        HttpUrlMethod urlMethod = getConfiguredHttpMethod();
  +        HttpMethod urlMethod = getConfiguredHttpMethod();
           // track request execution
           long start = System.currentTimeMillis();
           getHttpClient().executeMethod(urlMethod);
  @@ -173,10 +173,10 @@
        * @return a configured {@link HttpUrlMethod method}
        * @throws MalformedURLException when retrieving the URL fails
        */
  -    private HttpUrlMethod getConfiguredHttpMethod() throws 
  +    private HttpMethod getConfiguredHttpMethod() throws 
       MalformedURLException {
           // retrieve and configure url method
  -        HttpUrlMethod urlMethod = getHttpUrlMethod();
  +        HttpMethod urlMethod = getHttpMethod();
           urlMethod.setFollowRedirects(isFollowRedirects());
           // add request headers
           NameValuePair header = null;
  @@ -204,7 +204,7 @@
        * @param method the {@link HttpUrlMethod method} to configure
        * @throws MalformedURLException when {@link #getHttpUrlMethod()} does
        */
  -    protected void setParameters(HttpUrlMethod method) throws 
  +    protected void setParameters(HttpMethod method) throws 
       MalformedURLException {
           if (getParameters().size() > 0) {
               NameValuePair[] parameters = (NameValuePair[]) getParameters().
  @@ -231,14 +231,14 @@
        *
        * @return the shared http client from the session tag, or create a new one.
        */
  -    private HttpMultiClient getHttpClient() {
  +    private HttpClient getHttpClient() {
           SessionTag session = getSessionTag();
  -        HttpMultiClient client = null;
  +        HttpClient client = null;
           if (session != null) {
               client = session.getHttpClient();
               client.setStrictMode(session.isStrictMode());
           } else {
  -            client = new HttpMultiClient();
  +            client = new HttpClient();
           }
           return client;
       }
  
  
  
  1.3       +5 -5      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/HeadTag.java
  
  Index: HeadTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/HeadTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HeadTag.java	23 Oct 2002 16:35:35 -0000	1.2
  +++ HeadTag.java	4 Jan 2003 14:17:13 -0000	1.3
  @@ -63,8 +63,8 @@
   
   import java.net.MalformedURLException;
   
  -import org.apache.commons.httpclient.HttpUrlMethod;
  -import org.apache.commons.httpclient.methods.UrlHeadMethod;
  +import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.methods.HeadMethod;
   
   /**
    * A http get tag
  @@ -75,7 +75,7 @@
   public class HeadTag extends HttpTagSupport {
       
       /** the head method */
  -    private UrlHeadMethod _headMethod;
  +    private HeadMethod _headMethod;
       
       /**
        * Creates a new instance of HeadTag
  @@ -87,9 +87,9 @@
        * @return a url method for a Head request
        * @throws MalformedURLException when the url is bad
        */
  -    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +    protected HttpMethod getHttpMethod() throws MalformedURLException {
           if (_headMethod == null) {
  -            _headMethod = new UrlHeadMethod(getResolvedUrl());
  +            _headMethod = new HeadMethod(getResolvedUrl());
           }
           return _headMethod;
       }
  
  
  
  1.3       +5 -5      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/OptionsTag.java
  
  Index: OptionsTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/OptionsTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OptionsTag.java	23 Oct 2002 16:35:35 -0000	1.2
  +++ OptionsTag.java	4 Jan 2003 14:17:13 -0000	1.3
  @@ -63,8 +63,8 @@
   
   import java.net.MalformedURLException;
   
  -import org.apache.commons.httpclient.HttpUrlMethod;
  -import org.apache.commons.httpclient.methods.UrlOptionsMethod;
  +import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.methods.OptionsMethod;
   
   /**
    * A http get tag
  @@ -75,7 +75,7 @@
   public class OptionsTag extends HttpTagSupport {
       
       /** the options method */
  -    private UrlOptionsMethod _optionsMethod;
  +    private OptionsMethod _optionsMethod;
       
       /**
        * Creates a new instance of OptionsTag
  @@ -87,9 +87,9 @@
        * @return a url method for an options request
        * @throws MalformedURLException when the url is bad
        */
  -    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +    protected HttpMethod getHttpMethod() throws MalformedURLException {
           if (_optionsMethod == null) {
  -            _optionsMethod = new UrlOptionsMethod(getResolvedUrl());
  +            _optionsMethod = new OptionsMethod(getResolvedUrl());
           }
           return _optionsMethod;
       }
  
  
  
  1.5       +7 -7      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/PostTag.java
  
  Index: PostTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/PostTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PostTag.java	19 Dec 2002 00:29:22 -0000	1.4
  +++ PostTag.java	4 Jan 2003 14:17:13 -0000	1.5
  @@ -62,9 +62,9 @@
   package org.apache.commons.jelly.tags.http;
   
   import java.net.MalformedURLException;
  -import org.apache.commons.httpclient.HttpUrlMethod;
  +import org.apache.commons.httpclient.HttpMethod;
   import org.apache.commons.httpclient.NameValuePair;
  -import org.apache.commons.httpclient.methods.UrlPostMethod;
  +import org.apache.commons.httpclient.methods.PostMethod;
   
   
   /**
  @@ -75,7 +75,7 @@
   public class PostTag extends HttpTagSupport {
       
       /** the post method */
  -    private UrlPostMethod _postMethod;
  +    private PostMethod _postMethod;
   
       /** Creates a new instance of PostTag */
       public PostTag() {
  @@ -88,9 +88,9 @@
        * @throws MalformedURLException when the {@link getUrl() url} or
        * {@link #getPath() path} is invalid
        */
  -    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +    protected HttpMethod getHttpMethod() throws MalformedURLException {
           if (_postMethod == null) {
  -            _postMethod = new UrlPostMethod(getResolvedUrl());
  +            _postMethod = new PostMethod(getResolvedUrl());
           }
           return _postMethod;
       }
  @@ -101,12 +101,12 @@
        * This method <strong>must</strong> be called after 
        *  {@link getHttpUrlMethod}
        */
  -    protected void setParameters(HttpUrlMethod method) {
  +    protected void setParameters(HttpMethod method) {
           NameValuePair nvp = null;
           for (int index = 0; index < getParameters().size(); index++) {
               NameValuePair parameter = (NameValuePair) getParameters().
                   get(index);
  -            ((UrlPostMethod) method).addParameter(parameter);
  +            ((PostMethod) method).addParameter(parameter);
           }
       }
   
  
  
  
  1.4       +7 -7      jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/PutTag.java
  
  Index: PutTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/http/src/java/org/apache/commons/jelly/tags/http/PutTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PutTag.java	23 Oct 2002 16:35:35 -0000	1.3
  +++ PutTag.java	4 Jan 2003 14:17:13 -0000	1.4
  @@ -62,8 +62,8 @@
   package org.apache.commons.jelly.tags.http;
   
   import java.net.MalformedURLException;
  -import org.apache.commons.httpclient.HttpUrlMethod;
  -import org.apache.commons.httpclient.methods.UrlPutMethod;
  +import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.methods.PutMethod;
   
   
   /**
  @@ -75,22 +75,22 @@
   public class PutTag extends HttpTagSupport {
       
       /** the put method */
  -    private UrlPutMethod _putMethod;
  +    private PutMethod _putMethod;
   
       /** Creates a new instance of PutTag */
       public PutTag() {
       }
       
       /** 
  -     * Return a {@link HttpUrlMethod method} to be used for put'ing
  +     * Return a {@link HttpMethod method} to be used for put'ing
        *
  -     * @return a HttpUrlMethod implementation
  +     * @return a HttpMethod implementation
        * @throws MalformedURLException when the {@link getUrl() url} or
        * {@link #getPath() path} is invalid
        */
  -    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +    protected HttpMethod getHttpMethod() throws MalformedURLException {
           if (_putMethod == null) {
  -            _putMethod = new UrlPutMethod(getResolvedUrl());
  +            _putMethod = new PutMethod(getResolvedUrl());
           }
           return _putMethod;
       }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>