1
22
23 package com.liferay.portal.kernel.util;
24
25 import java.io.IOException;
26
27 import java.net.URL;
28
29 import java.util.Map;
30
31 import javax.portlet.ActionRequest;
32 import javax.portlet.RenderRequest;
33
34 import javax.servlet.http.Cookie;
35 import javax.servlet.http.HttpServletRequest;
36
37
43 public class HttpUtil {
44
45 public static String addParameter(String url, String name, boolean value) {
46 return getHttp().addParameter(url, name, value);
47 }
48
49 public static String addParameter(String url, String name, double value) {
50 return getHttp().addParameter(url, name, value);
51 }
52
53 public static String addParameter(String url, String name, int value) {
54 return getHttp().addParameter(url, name, value);
55 }
56
57 public static String addParameter(String url, String name, long value) {
58 return getHttp().addParameter(url, name, value);
59 }
60
61 public static String addParameter(String url, String name, short value) {
62 return getHttp().addParameter(url, name, value);
63 }
64
65 public static String addParameter(String url, String name, String value) {
66 return getHttp().addParameter(url, name, value);
67 }
68
69 public static String decodeURL(String url) {
70 return getHttp().decodeURL(url);
71 }
72
73 public static String decodeURL(String url, boolean unescapeSpace) {
74 return getHttp().decodeURL(url, unescapeSpace);
75 }
76
77 public static String encodeURL(String url) {
78 return getHttp().encodeURL(url);
79 }
80
81 public static String encodeURL(String url, boolean escapeSpaces) {
82 return getHttp().encodeURL(url, escapeSpaces);
83 }
84
85 public static String getCompleteURL(HttpServletRequest request) {
86 return getHttp().getCompleteURL(request);
87 }
88
89 public static Cookie[] getCookies() {
90 return getHttp().getCookies();
91 }
92
93 public static String getDomain(String url) {
94 return getHttp().getDomain(url);
95 }
96
97 public static Http getHttp() {
98 return _http;
99 }
100
101 public static String getParameter(String url, String name) {
102 return getHttp().getParameter(url, name);
103 }
104
105 public static String getParameter(
106 String url, String name, boolean escaped) {
107
108 return getHttp().getParameter(url, name, escaped);
109 }
110
111 public static Map<String, String[]> getParameterMap(String queryString) {
112 return getHttp().getParameterMap(queryString);
113 }
114
115 public static String getProtocol(ActionRequest actionRequest) {
116 return getHttp().getProtocol(actionRequest);
117 }
118
119 public static String getProtocol(boolean secure) {
120 return getHttp().getProtocol(secure);
121 }
122
123 public static String getProtocol(HttpServletRequest request) {
124 return getHttp().getProtocol(request);
125 }
126
127 public static String getProtocol(RenderRequest renderRequest) {
128 return getHttp().getProtocol(renderRequest);
129 }
130
131 public static String getProtocol(String url) {
132 return getHttp().getProtocol(url);
133 }
134
135 public static String getQueryString(String url) {
136 return getHttp().getQueryString(url);
137 }
138
139 public static String getRequestURL(HttpServletRequest request) {
140 return getHttp().getRequestURL(request);
141 }
142
143 public static boolean hasDomain(String url) {
144 return getHttp().hasDomain(url);
145 }
146
147 public static boolean hasProtocol(String url) {
148 return getHttp().hasProtocol(url);
149 }
150
151 public static boolean hasProxyConfig() {
152 return getHttp().hasProxyConfig();
153 }
154
155 public static boolean isNonProxyHost(String host) {
156 return getHttp().isNonProxyHost(host);
157 }
158
159 public static boolean isProxyHost(String host) {
160 return getHttp().isProxyHost(host);
161 }
162
163 public static Map<String, String[]> parameterMapFromString(
164 String queryString) {
165
166 return getHttp().parameterMapFromString(queryString);
167 }
168
169 public static String parameterMapToString(
170 Map<String, String[]> parameterMap) {
171
172 return getHttp().parameterMapToString(parameterMap);
173 }
174
175 public static String parameterMapToString(
176 Map<String, String[]> parameterMap, boolean addQuestion) {
177
178 return getHttp().parameterMapToString(parameterMap, addQuestion);
179 }
180
181 public static String protocolize(String url, ActionRequest actionRequest) {
182 return getHttp().protocolize(url, actionRequest);
183 }
184
185 public static String protocolize(String url, boolean secure) {
186 return getHttp().protocolize(url, secure);
187 }
188
189 public static String protocolize(String url, HttpServletRequest request) {
190 return getHttp().protocolize(url, request);
191 }
192
193 public static String protocolize(String url, RenderRequest renderRequest) {
194 return getHttp().protocolize(url, renderRequest);
195 }
196
197 public static String removeDomain(String url) {
198 return getHttp().removeDomain(url);
199 }
200
201 public static String removeParameter(String url, String name) {
202 return getHttp().removeParameter(url, name);
203 }
204
205 public static String removeProtocol(String url) {
206 return getHttp().removeProtocol(url);
207 }
208
209 public static String setParameter(String url, String name, boolean value) {
210 return getHttp().setParameter(url, name, value);
211 }
212
213 public static String setParameter(String url, String name, double value) {
214 return getHttp().setParameter(url, name, value);
215 }
216
217 public static String setParameter(String url, String name, int value) {
218 return getHttp().setParameter(url, name, value);
219 }
220
221 public static String setParameter(String url, String name, long value) {
222 return getHttp().setParameter(url, name, value);
223 }
224
225 public static String setParameter(String url, String name, short value) {
226 return getHttp().setParameter(url, name, value);
227 }
228
229 public static String setParameter(String url, String name, String value) {
230 return getHttp().setParameter(url, name, value);
231 }
232
233
236 public static void submit(String location) throws IOException {
237 getHttp().submit(location);
238 }
239
240
243 public static void submit(String location, boolean post)
244 throws IOException {
245
246 getHttp().submit(location, post);
247 }
248
249
252 public static void submit(String location, Cookie[] cookies)
253 throws IOException {
254
255 getHttp().submit(location, cookies);
256 }
257
258
261 public static void submit(String location, Cookie[] cookies, boolean post)
262 throws IOException {
263
264 getHttp().submit(location, cookies, post);
265 }
266
267
270 public static void submit(
271 String location, Cookie[] cookies, Http.Body body, boolean post)
272 throws IOException {
273
274 getHttp().submit(location, cookies, body, post);
275 }
276
277
280 public static void submit(
281 String location, Cookie[] cookies, Map<String, String> parts,
282 boolean post)
283 throws IOException {
284
285 getHttp().submit(location, cookies, parts, post);
286 }
287
288 public static byte[] URLtoByteArray(Http.Options options)
289 throws IOException {
290
291 return getHttp().URLtoByteArray(options);
292 }
293
294 public static byte[] URLtoByteArray(String location) throws IOException {
295 return getHttp().URLtoByteArray(location);
296 }
297
298 public static byte[] URLtoByteArray(String location, boolean post)
299 throws IOException {
300
301 return getHttp().URLtoByteArray(location, post);
302 }
303
304
307 public static byte[] URLtoByteArray(String location, Cookie[] cookies)
308 throws IOException {
309
310 return getHttp().URLtoByteArray(location, cookies);
311 }
312
313
316 public static byte[] URLtoByteArray(
317 String location, Cookie[] cookies, boolean post)
318 throws IOException {
319
320 return getHttp().URLtoByteArray(location, cookies, post);
321 }
322
323
326 public static byte[] URLtoByteArray(
327 String location, Cookie[] cookies, Http.Auth auth, Http.Body body,
328 boolean post)
329 throws IOException {
330
331 return getHttp().URLtoByteArray(location, cookies, auth, body, post);
332 }
333
334
337 public static byte[] URLtoByteArray(
338 String location, Cookie[] cookies, Http.Auth auth,
339 Map<String, String> parts, boolean post)
340 throws IOException {
341
342 return getHttp().URLtoByteArray(location, cookies, auth, parts, post);
343 }
344
345
348 public static byte[] URLtoByteArray(
349 String location, Cookie[] cookies, Http.Body body, boolean post)
350 throws IOException {
351
352 return getHttp().URLtoByteArray(location, cookies, body, post);
353 }
354
355
358 public static byte[] URLtoByteArray(
359 String location, Cookie[] cookies, Map<String, String> parts,
360 boolean post)
361 throws IOException {
362
363 return getHttp().URLtoByteArray(location, cookies, parts, post);
364 }
365
366 public static String URLtoString(Http.Options options) throws IOException {
367 return getHttp().URLtoString(options);
368 }
369
370 public static String URLtoString(String location) throws IOException {
371 return getHttp().URLtoString(location);
372 }
373
374 public static String URLtoString(String location, boolean post)
375 throws IOException {
376
377 return getHttp().URLtoString(location, post);
378 }
379
380
383 public static String URLtoString(String location, Cookie[] cookies)
384 throws IOException {
385
386 return getHttp().URLtoString(location, cookies);
387 }
388
389
392 public static String URLtoString(
393 String location, Cookie[] cookies, boolean post)
394 throws IOException {
395
396 return getHttp().URLtoString(location, cookies, post);
397 }
398
399
402 public static String URLtoString(
403 String location, Cookie[] cookies, Http.Auth auth, Http.Body body,
404 boolean post)
405 throws IOException {
406
407 return getHttp().URLtoString(location, cookies, auth, body, post);
408 }
409
410
413 public static String URLtoString(
414 String location, Cookie[] cookies, Http.Auth auth,
415 Map<String, String> parts, boolean post)
416 throws IOException {
417
418 return getHttp().URLtoString(location, cookies, auth, parts, post);
419 }
420
421
424 public static String URLtoString(
425 String location, Cookie[] cookies, Http.Body body, boolean post)
426 throws IOException {
427
428 return getHttp().URLtoString(location, cookies, body, post);
429 }
430
431
434 public static String URLtoString(
435 String location, Cookie[] cookies, Map<String, String> parts,
436 boolean post)
437 throws IOException {
438
439 return getHttp().URLtoString(location, cookies, parts, post);
440 }
441
442
445 public static String URLtoString(
446 String location, String host, int port, String realm,
447 String username, String password)
448 throws IOException {
449
450 return getHttp().URLtoString(
451 location, host, port, realm, username, password);
452 }
453
454
465 public static String URLtoString(URL url) throws IOException {
466 return getHttp().URLtoString(url);
467 }
468
469 public void setHttp(Http http) {
470 _http = http;
471 }
472
473 private static Http _http;
474
475 }