View Javadoc

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