View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  
28  package org.apache.hc.client5.http.async.methods;
29  
30  import java.net.URI;
31  
32  import org.apache.hc.core5.http.HttpHost;
33  import org.apache.hc.core5.http.Method;
34  
35  /**
36   * Common HTTP methods using {@link SimpleHttpRequest} as a HTTP request message representation.
37   *
38   * @since 5.0
39   *
40   * @deprecated Use {@link SimpleRequestBuilder}.
41   */
42  @Deprecated
43  public final class SimpleHttpRequests {
44  
45      /**
46       * Creates a new BasicHttpRequest for the given {@code method} and {@code String} URI.
47       *
48       * @param method A method supported by this class.
49       * @param uri a non-null request string URI.
50       * @return A new BasicHttpRequest.
51       */
52      public static SimpleHttpRequest create(final String method, final String uri) {
53           return create(Method.normalizedValueOf(method), uri);
54      }
55  
56      /**
57       * Creates a new BasicHttpRequest for the given {@code method} and {@code URI}.
58       *
59       * @param method A method supported by this class.
60       * @param uri a non-null request URI.
61       * @return A new BasicHttpRequest.
62       */
63      public static SimpleHttpRequest create(final String method, final URI uri) {
64          return create(Method.normalizedValueOf(method), uri);
65      }
66  
67      public static SimpleHttpRequest delete(final String uri) {
68          return delete(URI.create(uri));
69      }
70  
71      public static SimpleHttpRequest delete(final URI uri) {
72          return create(Method.DELETE, uri);
73      }
74  
75      public static SimpleHttpRequest delete(final HttpHost host, final String path) {
76          return create(Method.DELETE, host, path);
77      }
78  
79      public static SimpleHttpRequest get(final String uri) {
80          return get(URI.create(uri));
81      }
82  
83      public static SimpleHttpRequest get(final URI uri) {
84          return create(Method.GET, uri);
85      }
86  
87      public static SimpleHttpRequest get(final HttpHost host, final String path) {
88          return create(Method.GET, host, path);
89      }
90  
91      public static SimpleHttpRequest head(final String uri) {
92          return head(URI.create(uri));
93      }
94  
95      public static SimpleHttpRequest head(final URI uri) {
96          return create(Method.HEAD, uri);
97      }
98  
99      public static SimpleHttpRequest head(final HttpHost host, final String path) {
100         return create(Method.HEAD, host, path);
101     }
102 
103     public static SimpleHttpRequest options(final String uri) {
104         return options(URI.create(uri));
105     }
106 
107     public static SimpleHttpRequest options(final URI uri) {
108         return create(Method.OPTIONS, uri);
109     }
110 
111     public static SimpleHttpRequest options(final HttpHost host, final String path) {
112         return create(Method.OPTIONS, host, path);
113     }
114 
115     public static SimpleHttpRequest patch(final String uri) {
116         return patch(URI.create(uri));
117     }
118 
119     public static SimpleHttpRequest patch(final URI uri) {
120         return create(Method.PATCH, uri);
121     }
122 
123     public static SimpleHttpRequest patch(final HttpHost host, final String path) {
124         return create(Method.PATCH, host, path);
125     }
126 
127     public static SimpleHttpRequest post(final String uri) {
128         return post(URI.create(uri));
129     }
130 
131     public static SimpleHttpRequest post(final URI uri) {
132         return create(Method.POST, uri);
133     }
134 
135     public static SimpleHttpRequest post(final HttpHost host, final String path) {
136         return create(Method.POST, host, path);
137     }
138 
139     public static SimpleHttpRequest put(final String uri) {
140         return put(URI.create(uri));
141     }
142 
143     public static SimpleHttpRequest put(final URI uri) {
144         return create(Method.PUT, uri);
145     }
146 
147     public static SimpleHttpRequest put(final HttpHost host, final String path) {
148         return create(Method.PUT, host, path);
149     }
150 
151     public static SimpleHttpRequest trace(final String uri) {
152         return trace(URI.create(uri));
153     }
154 
155     public static SimpleHttpRequest trace(final URI uri) {
156         return create(Method.TRACE, uri);
157     }
158 
159     public static SimpleHttpRequest trace(final HttpHost host, final String path) {
160         return create(Method.TRACE, host, path);
161     }
162 
163     /**
164      * Creates a request object of the exact subclass of {@link SimpleHttpRequest}.
165      *
166      * @param uri a non-null URI String.
167      * @return a new subclass of SimpleHttpRequest
168      */
169     public static SimpleHttpRequest create(final Method method, final String uri) {
170         return create(method, URI.create(uri));
171     }
172 
173     /**
174      * Creates a request object of the exact subclass of {@link SimpleHttpRequest}.
175      *
176      * @param uri a non-null URI.
177      * @return a new subclass of SimpleHttpRequest
178      */
179     public static SimpleHttpRequest create(final Method method, final URI uri) {
180         return new SimpleHttpRequest(method, uri);
181     }
182 
183     /**
184      * Creates a request object of the exact subclass of {@link SimpleHttpRequest}.
185      *
186      * @param host HTTP host.
187      * @param path request path.
188      * @return a new subclass of SimpleHttpRequest
189      */
190     public static SimpleHttpRequest create(final Method method, final HttpHost host, final String path) {
191         return new SimpleHttpRequest(method, host, path);
192     }
193 
194 }