1. /*
  2. * $Header: /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: 1.29 $
  4. * $Date: 2004/06/13 20:22:19 $
  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. package org.apache.commons.httpclient.methods;
  30. import org.apache.commons.httpclient.HttpMethodBase;
  31. import org.apache.commons.logging.Log;
  32. import org.apache.commons.logging.LogFactory;
  33. /**
  34. * Implements the HTTP GET method.
  35. * <p>
  36. * The HTTP GET method is defined in section 9.3 of
  37. * <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
  38. * <blockquote>
  39. * The GET method means retrieve whatever information (in the form of an
  40. * entity) is identified by the Request-URI. If the Request-URI refers
  41. * to a data-producing process, it is the produced data which shall be
  42. * returned as the entity in the response and not the source text of the
  43. * process, unless that text happens to be the output of the process.
  44. * </blockquote>
  45. * </p>
  46. * <p>
  47. * GetMethods will follow redirect requests from the http server by default.
  48. * This behavour can be disabled by calling setFollowRedirects(false).</p>
  49. *
  50. * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  51. * @author Sung-Gu Park
  52. * @author Sean C. Sullivan
  53. * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
  54. * @author <a href="mailto:jsdever@apache.org">Jeff Dever</a>
  55. *
  56. * @version $Revision: 1.29 $
  57. * @since 1.0
  58. */
  59. public class GetMethod extends HttpMethodBase {
  60. // -------------------------------------------------------------- Constants
  61. /** Log object for this class. */
  62. private static final Log LOG = LogFactory.getLog(GetMethod.class);
  63. // ----------------------------------------------------------- Constructors
  64. /**
  65. * No-arg constructor.
  66. *
  67. * @since 1.0
  68. */
  69. public GetMethod() {
  70. setFollowRedirects(true);
  71. }
  72. /**
  73. * Constructor specifying a URI.
  74. *
  75. * @param uri either an absolute or relative URI
  76. *
  77. * @since 1.0
  78. */
  79. public GetMethod(String uri) {
  80. super(uri);
  81. LOG.trace("enter GetMethod(String)");
  82. setFollowRedirects(true);
  83. }
  84. // --------------------------------------------------------- Public Methods
  85. /**
  86. * Returns <tt>"GET"</tt>.
  87. *
  88. * @return <tt>"GET"</tt>
  89. *
  90. * @since 2.0
  91. */
  92. public String getName() {
  93. return "GET";
  94. }
  95. // ------------------------------------------------------------- Properties
  96. /**
  97. * Recycles the HTTP method so that it can be used again.
  98. * Note that all of the instance variables will be reset
  99. * once this method has been called. This method will also
  100. * release the connection being used by this HTTP method.
  101. *
  102. * @see #releaseConnection()
  103. *
  104. * @since 1.0
  105. *
  106. * @deprecated no longer supported and will be removed in the future
  107. * version of HttpClient
  108. */
  109. public void recycle() {
  110. LOG.trace("enter GetMethod.recycle()");
  111. super.recycle();
  112. setFollowRedirects(true);
  113. }
  114. }