From 254de778a53e7afb6d661f943712d591162c87f8 Mon Sep 17 00:00:00 2001
From: Oleg Kalnichevski
+ * The HTTP GET method is defined in section 9.3 of
+ * RFC2616:
+ *
+ * The GET method means retrieve whatever information (in the form of an
+ * entity) is identified by the Request-URI. If the Request-URI refers
+ * to a data-producing process, it is the produced data which shall be
+ * returned as the entity in the response and not the source text of the
+ * process, unless that text happens to be the output of the process.
+ *
+ *
+ * GetMethods will follow redirect requests from the http server by default. + * This behavour can be disabled by calling setFollowRedirects(false).
+ * + * @version $Revision$ + * + * @since 4.0 + */ +public class HttpGet extends HttpRequestBase { + + public final static String METHOD_NAME = "GET"; + + public HttpGet() { + super(); + } + + public HttpGet(final URI uri) { + super(); + setURI(uri); + } + + public HttpGet(final String uri) throws URISyntaxException { + super(); + setURI(new URI(uri)); + } + + public String getMethod() { + return METHOD_NAME; + } + +} diff --git a/src/java/org/apache/http/client/methods/HttpHead.java b/src/java/org/apache/http/client/methods/HttpHead.java new file mode 100644 index 000000000..20d813519 --- /dev/null +++ b/src/java/org/apache/http/client/methods/HttpHead.java @@ -0,0 +1,80 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *+ * The HTTP HEAD method is defined in section 9.4 of + * RFC2616: + *
+ * The HEAD method is identical to GET except that the server MUST NOT + * return a message-body in the response. The metainformation contained + * in the HTTP headers in response to a HEAD request SHOULD be identical + * to the information sent in response to a GET request. This method can + * be used for obtaining metainformation about the entity implied by the + * request without transferring the entity-body itself. This method is + * often used for testing hypertext links for validity, accessibility, + * and recent modification. + *+ * + * + * @version $Revision$ + * + * @since 4.0 + */ +public class HttpHead extends HttpRequestBase { + + public final static String METHOD_NAME = "HEAD"; + + public HttpHead() { + super(); + } + + public HttpHead(final URI uri) { + super(); + setURI(uri); + } + + public HttpHead(final String uri) throws URISyntaxException { + super(); + setURI(new URI(uri)); + } + + public String getMethod() { + return METHOD_NAME; + } + +} diff --git a/src/java/org/apache/http/client/methods/HttpOptions.java b/src/java/org/apache/http/client/methods/HttpOptions.java new file mode 100644 index 000000000..46cc3e1ea --- /dev/null +++ b/src/java/org/apache/http/client/methods/HttpOptions.java @@ -0,0 +1,78 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *
+ * The HTTP OPTIONS method is defined in section 9.2 of + * RFC2616: + *
+ * The OPTIONS method represents a request for information about the + * communication options available on the request/response chain + * identified by the Request-URI. This method allows the client to + * determine the options and/or requirements associated with a resource, + * or the capabilities of a server, without implying a resource action + * or initiating a resource retrieval. + *+ * + * + * @version $Revision$ + * + * @since 4.0 + */ +public class HttpOptions extends HttpRequestBase { + + public final static String METHOD_NAME = "OPTIONS"; + + public HttpOptions() { + super(); + } + + public HttpOptions(final URI uri) { + super(); + setURI(uri); + } + + public HttpOptions(final String uri) throws URISyntaxException { + super(); + setURI(new URI(uri)); + } + + public String getMethod() { + return METHOD_NAME; + } + +} diff --git a/src/java/org/apache/http/client/methods/HttpPost.java b/src/java/org/apache/http/client/methods/HttpPost.java new file mode 100644 index 000000000..a4e64bdaf --- /dev/null +++ b/src/java/org/apache/http/client/methods/HttpPost.java @@ -0,0 +1,84 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *
+ * The HTTP POST method is defined in section 9.5 of + * RFC2616: + *
+ * The POST method is used to request that the origin server accept the entity + * enclosed in the request as a new subordinate of the resource identified by + * the Request-URI in the Request-Line. POST is designed to allow a uniform + * method to cover the following functions: + *+ * + * + * @version $Revision$ + * + * @since 4.0 + */ +public class HttpPost extends HttpEntityEnclosingRequestBase { + + public final static String METHOD_NAME = "POST"; + + public HttpPost() { + super(); + } + + public HttpPost(final URI uri) { + super(); + setURI(uri); + } + + public HttpPost(final String uri) throws URISyntaxException { + super(); + setURI(new URI(uri)); + } + + public String getMethod() { + return METHOD_NAME; + } + +} diff --git a/src/java/org/apache/http/client/methods/HttpPut.java b/src/java/org/apache/http/client/methods/HttpPut.java new file mode 100644 index 000000000..d69874147 --- /dev/null +++ b/src/java/org/apache/http/client/methods/HttpPut.java @@ -0,0 +1,76 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *+ *
+ *- Annotation of existing resources
+ *- Posting a message to a bulletin board, newsgroup, mailing list, or + * similar group of articles
+ *- Providing a block of data, such as the result of submitting a form, + * to a data-handling process
+ *- Extending a database through an append operation
+ *
+ * The HTTP PUT method is defined in section 9.6 of + * RFC2616: + *
+ * The PUT method requests that the enclosed entity be stored under the + * supplied Request-URI. If the Request-URI refers to an already + * existing resource, the enclosed entity SHOULD be considered as a + * modified version of the one residing on the origin server. + *+ * + * + * @version $Revision$ + * + * @since 4.0 + */ +public class HttpPut extends HttpEntityEnclosingRequestBase { + + public final static String METHOD_NAME = "PUT"; + + public HttpPut() { + super(); + } + + public HttpPut(final URI uri) { + super(); + setURI(uri); + } + + public HttpPut(final String uri) throws URISyntaxException { + super(); + setURI(new URI(uri)); + } + + public String getMethod() { + return METHOD_NAME; + } + +} diff --git a/src/java/org/apache/http/client/methods/HttpRequestBase.java b/src/java/org/apache/http/client/methods/HttpRequestBase.java new file mode 100644 index 000000000..0adba88fc --- /dev/null +++ b/src/java/org/apache/http/client/methods/HttpRequestBase.java @@ -0,0 +1,87 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *
+ * The HTTP TRACE method is defined in section 9.6 of + * RFC2616: + *
+ * The TRACE method is used to invoke a remote, application-layer loop- + * back of the request message. The final recipient of the request + * SHOULD reflect the message received back to the client as the + * entity-body of a 200 (OK) response. The final recipient is either the + * origin server or the first proxy or gateway to receive a Max-Forwards + * value of zero (0) in the request (see section 14.31). A TRACE request + * MUST NOT include an entity. + *+ * + * + * @version $Revision$ + * + * @since 4.0 + */ +public class HttpTrace extends HttpRequestBase { + + public final static String METHOD_NAME = "TRACE"; + + public HttpTrace() { + super(); + } + + public HttpTrace(final URI uri) { + super(); + setURI(uri); + } + + public HttpTrace(final String uri) throws URISyntaxException { + super(); + setURI(new URI(uri)); + } + + public String getMethod() { + return METHOD_NAME; + } + +} diff --git a/src/test/org/apache/http/impl/conn/TestLocalServer.java b/src/test/org/apache/http/impl/conn/TestLocalServer.java index e1407081a..1167961d7 100644 --- a/src/test/org/apache/http/impl/conn/TestLocalServer.java +++ b/src/test/org/apache/http/impl/conn/TestLocalServer.java @@ -37,11 +37,11 @@ import org.apache.http.HttpClientConnection; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.localserver.LocalTestServer; import org.apache.http.localserver.ServerTestBase; -import org.apache.http.message.HttpGet; -import org.apache.http.message.HttpPost; import org.apache.http.util.EntityUtils;