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