View Javadoc

1   /*
2    * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/methods/GetMethod.java,v 1.29 2004/06/13 20:22:19 olegk Exp $
3    * $Revision: 155418 $
4    * $Date: 2005-02-26 08:01:52 -0500 (Sat, 26 Feb 2005) $
5    *
6    * ====================================================================
7    *
8    *  Copyright 1999-2004 The Apache Software Foundation
9    *
10   *  Licensed under the Apache License, Version 2.0 (the "License");
11   *  you may not use this file except in compliance with the License.
12   *  You may obtain a copy of the License at
13   *
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   *
16   *  Unless required by applicable law or agreed to in writing, software
17   *  distributed under the License is distributed on an "AS IS" BASIS,
18   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   *  See the License for the specific language governing permissions and
20   *  limitations under the License.
21   * ====================================================================
22   *
23   * This software consists of voluntary contributions made by many
24   * individuals on behalf of the Apache Software Foundation.  For more
25   * information on the Apache Software Foundation, please see
26   * <http://www.apache.org/>.
27   *
28   */
29  
30  package org.apache.commons.httpclient.methods;
31  
32  import org.apache.commons.httpclient.HttpMethodBase;
33  import org.apache.commons.logging.Log;
34  import org.apache.commons.logging.LogFactory;
35  
36  /***
37   * Implements the HTTP GET method.
38   * <p>
39   * The HTTP GET method is defined in section 9.3 of
40   * <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
41   * <blockquote>
42   * The GET method means retrieve whatever information (in the form of an
43   * entity) is identified by the Request-URI. If the Request-URI refers
44   * to a data-producing process, it is the produced data which shall be
45   * returned as the entity in the response and not the source text of the
46   * process, unless that text happens to be the output of the process.
47   * </blockquote>
48   * </p>
49   * <p>
50   * GetMethods will follow redirect requests from the http server by default.
51   * This behavour can be disabled by calling setFollowRedirects(false).</p>
52   *
53   * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
54   * @author Sung-Gu Park
55   * @author Sean C. Sullivan
56   * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
57   * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
58   * 
59   * @version $Revision: 155418 $
60   * @since 1.0
61   */
62  public class GetMethod extends HttpMethodBase {
63  
64      // -------------------------------------------------------------- Constants
65  
66      /*** Log object for this class. */
67      private static final Log LOG = LogFactory.getLog(GetMethod.class);
68  
69      // ----------------------------------------------------------- Constructors
70  
71      /***
72       * No-arg constructor.
73       * 
74       * @since 1.0
75       */
76      public GetMethod() {
77          setFollowRedirects(true);
78      }
79  
80      /***
81       * Constructor specifying a URI.
82       *
83       * @param uri either an absolute or relative URI
84       * 
85       * @since 1.0
86       */
87      public GetMethod(String uri) {
88          super(uri);
89          LOG.trace("enter GetMethod(String)");
90          setFollowRedirects(true);
91      }
92  
93      // --------------------------------------------------------- Public Methods
94  
95      /***
96       * Returns <tt>"GET"</tt>.
97       * 
98       * @return <tt>"GET"</tt>
99       * 
100      * @since 2.0
101      */
102     public String getName() {
103         return "GET";
104     }
105 
106     // ------------------------------------------------------------- Properties
107 
108     /***
109      * Recycles the HTTP method so that it can be used again.
110      * Note that all of the instance variables will be reset
111      * once this method has been called. This method will also
112      * release the connection being used by this HTTP method.
113      * 
114      * @see #releaseConnection()
115      * 
116      * @since 1.0
117      * 
118      * @deprecated no longer supported and will be removed in the future
119      *             version of HttpClient
120      */
121     public void recycle() {
122         LOG.trace("enter GetMethod.recycle()");
123 
124         super.recycle();
125         setFollowRedirects(true);
126     }
127 
128 }