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
42 public class HttpUtil {
43
44 public static String addParameter(String url, String name, boolean value) {
45 return getHttp().addParameter(url, name, value);
46 }
47
48 public static String addParameter(String url, String name, double value) {
49 return getHttp().addParameter(url, name, value);
50 }
51
52 public static String addParameter(String url, String name, int value) {
53 return getHttp().addParameter(url, name, value);
54 }
55
56 public static String addParameter(String url, String name, long value) {
57 return getHttp().addParameter(url, name, value);
58 }
59
60 public static String addParameter(String url, String name, short value) {
61 return getHttp().addParameter(url, name, value);
62 }
63
64 public static String addParameter(String url, String name, String value) {
65 return getHttp().addParameter(url, name, value);
66 }
67
68 public static String decodeURL(String url) {
69 return getHttp().decodeURL(url);
70 }
71
72 public static String decodeURL(String url, boolean unescapeSpace) {
73 return getHttp().decodeURL(url, unescapeSpace);
74 }
75
76 public static String encodeURL(String url) {
77 return getHttp().encodeURL(url);
78 }
79
80 public static String encodeURL(String url, boolean escapeSpaces) {
81 return getHttp().encodeURL(url, escapeSpaces);
82 }
83
84 public static String getCompleteURL(HttpServletRequest request) {
85 return getHttp().getCompleteURL(request);
86 }
87
88 public static Cookie[] getCookies() {
89 return getHttp().getCookies();
90 }
91
92 public static String getDomain(String url) {
93 return getHttp().getDomain(url);
94 }
95
96 public static String getIpAddress(String url) {
97 return getHttp().getIpAddress(url);
98 }
99
100 public static Http getHttp() {
101 return _http;
102 }
103
104 public static String getParameter(String url, String name) {
105 return getHttp().getParameter(url, name);
106 }
107
108 public static String getParameter(
109 String url, String name, boolean escaped) {
110
111 return getHttp().getParameter(url, name, escaped);
112 }
113
114 public static Map<String, String[]> getParameterMap(String queryString) {
115 return getHttp().getParameterMap(queryString);
116 }
117
118 public static String getProtocol(ActionRequest actionRequest) {
119 return getHttp().getProtocol(actionRequest);
120 }
121
122 public static String getProtocol(boolean secure) {
123 return getHttp().getProtocol(secure);
124 }
125
126 public static String getProtocol(HttpServletRequest request) {
127 return getHttp().getProtocol(request);
128 }
129
130 public static String getProtocol(RenderRequest renderRequest) {
131 return getHttp().getProtocol(renderRequest);
132 }
133
134 public static String getProtocol(String url) {
135 return getHttp().getProtocol(url);
136 }
137
138 public static String getQueryString(String url) {
139 return getHttp().getQueryString(url);
140 }
141
142 public static String getRequestURL(HttpServletRequest request) {
143 return getHttp().getRequestURL(request);
144 }
145
146 public static boolean hasDomain(String url) {
147 return getHttp().hasDomain(url);
148 }
149
150 public static boolean hasProtocol(String url) {
151 return getHttp().hasProtocol(url);
152 }
153
154 public static boolean hasProxyConfig() {
155 return getHttp().hasProxyConfig();
156 }
157
158 public static boolean isNonProxyHost(String host) {
159 return getHttp().isNonProxyHost(host);
160 }
161
162 public static boolean isProxyHost(String host) {
163 return getHttp().isProxyHost(host);
164 }
165
166 public static Map<String, String[]> parameterMapFromString(
167 String queryString) {
168
169 return getHttp().parameterMapFromString(queryString);
170 }
171
172 public static String parameterMapToString(
173 Map<String, String[]> parameterMap) {
174
175 return getHttp().parameterMapToString(parameterMap);
176 }
177
178 public static String parameterMapToString(
179 Map<String, String[]> parameterMap, boolean addQuestion) {
180
181 return getHttp().parameterMapToString(parameterMap, addQuestion);
182 }
183
184 public static String protocolize(String url, ActionRequest actionRequest) {
185 return getHttp().protocolize(url, actionRequest);
186 }
187
188 public static String protocolize(String url, boolean secure) {
189 return getHttp().protocolize(url, secure);
190 }
191
192 public static String protocolize(String url, HttpServletRequest request) {
193 return getHttp().protocolize(url, request);
194 }
195
196 public static String protocolize(String url, RenderRequest renderRequest) {
197 return getHttp().protocolize(url, renderRequest);
198 }
199
200 public static String removeDomain(String url) {
201 return getHttp().removeDomain(url);
202 }
203
204 public static String removeParameter(String url, String name) {
205 return getHttp().removeParameter(url, name);
206 }
207
208 public static String removeProtocol(String url) {
209 return getHttp().removeProtocol(url);
210 }
211
212 public static String setParameter(String url, String name, boolean value) {
213 return getHttp().setParameter(url, name, value);
214 }
215
216 public static String setParameter(String url, String name, double value) {
217 return getHttp().setParameter(url, name, value);
218 }
219
220 public static String setParameter(String url, String name, int value) {
221 return getHttp().setParameter(url, name, value);
222 }
223
224 public static String setParameter(String url, String name, long value) {
225 return getHttp().setParameter(url, name, value);
226 }
227
228 public static String setParameter(String url, String name, short value) {
229 return getHttp().setParameter(url, name, value);
230 }
231
232 public static String setParameter(String url, String name, String value) {
233 return getHttp().setParameter(url, name, value);
234 }
235
236
239 public static void submit(String location) throws IOException {
240 getHttp().submit(location);
241 }
242
243
246 public static void submit(String location, boolean post)
247 throws IOException {
248
249 getHttp().submit(location, post);
250 }
251
252
255 public static void submit(String location, Cookie[] cookies)
256 throws IOException {
257
258 getHttp().submit(location, cookies);
259 }
260
261
264 public static void submit(String location, Cookie[] cookies, boolean post)
265 throws IOException {
266
267 getHttp().submit(location, cookies, post);
268 }
269
270
273 public static void submit(
274 String location, Cookie[] cookies, Http.Body body, boolean post)
275 throws IOException {
276
277 getHttp().submit(location, cookies, body, post);
278 }
279
280
283 public static void submit(
284 String location, Cookie[] cookies, Map<String, String> parts,
285 boolean post)
286 throws IOException {
287
288 getHttp().submit(location, cookies, parts, post);
289 }
290
291 public static byte[] URLtoByteArray(Http.Options options)
292 throws IOException {
293
294 return getHttp().URLtoByteArray(options);
295 }
296
297 public static byte[] URLtoByteArray(String location) throws IOException {
298 return getHttp().URLtoByteArray(location);
299 }
300
301 public static byte[] URLtoByteArray(String location, boolean post)
302 throws IOException {
303
304 return getHttp().URLtoByteArray(location, post);
305 }
306
307
310 public static byte[] URLtoByteArray(String location, Cookie[] cookies)
311 throws IOException {
312
313 return getHttp().URLtoByteArray(location, cookies);
314 }
315
316
319 public static byte[] URLtoByteArray(
320 String location, Cookie[] cookies, boolean post)
321 throws IOException {
322
323 return getHttp().URLtoByteArray(location, cookies, post);
324 }
325
326
329 public static byte[] URLtoByteArray(
330 String location, Cookie[] cookies, Http.Auth auth, Http.Body body,
331 boolean post)
332 throws IOException {
333
334 return getHttp().URLtoByteArray(location, cookies, auth, body, post);
335 }
336
337
340 public static byte[] URLtoByteArray(
341 String location, Cookie[] cookies, Http.Auth auth,
342 Map<String, String> parts, boolean post)
343 throws IOException {
344
345 return getHttp().URLtoByteArray(location, cookies, auth, parts, post);
346 }
347
348
351 public static byte[] URLtoByteArray(
352 String location, Cookie[] cookies, Http.Body body, boolean post)
353 throws IOException {
354
355 return getHttp().URLtoByteArray(location, cookies, body, post);
356 }
357
358
361 public static byte[] URLtoByteArray(
362 String location, Cookie[] cookies, Map<String, String> parts,
363 boolean post)
364 throws IOException {
365
366 return getHttp().URLtoByteArray(location, cookies, parts, post);
367 }
368
369 public static String URLtoString(Http.Options options) throws IOException {
370 return getHttp().URLtoString(options);
371 }
372
373 public static String URLtoString(String location) throws IOException {
374 return getHttp().URLtoString(location);
375 }
376
377 public static String URLtoString(String location, boolean post)
378 throws IOException {
379
380 return getHttp().URLtoString(location, post);
381 }
382
383
386 public static String URLtoString(String location, Cookie[] cookies)
387 throws IOException {
388
389 return getHttp().URLtoString(location, cookies);
390 }
391
392
395 public static String URLtoString(
396 String location, Cookie[] cookies, boolean post)
397 throws IOException {
398
399 return getHttp().URLtoString(location, cookies, post);
400 }
401
402
405 public static String URLtoString(
406 String location, Cookie[] cookies, Http.Auth auth, Http.Body body,
407 boolean post)
408 throws IOException {
409
410 return getHttp().URLtoString(location, cookies, auth, body, post);
411 }
412
413
416 public static String URLtoString(
417 String location, Cookie[] cookies, Http.Auth auth,
418 Map<String, String> parts, boolean post)
419 throws IOException {
420
421 return getHttp().URLtoString(location, cookies, auth, parts, post);
422 }
423
424
427 public static String URLtoString(
428 String location, Cookie[] cookies, Http.Body body, boolean post)
429 throws IOException {
430
431 return getHttp().URLtoString(location, cookies, body, post);
432 }
433
434
437 public static String URLtoString(
438 String location, Cookie[] cookies, Map<String, String> parts,
439 boolean post)
440 throws IOException {
441
442 return getHttp().URLtoString(location, cookies, parts, post);
443 }
444
445
448 public static String URLtoString(
449 String location, String host, int port, String realm,
450 String username, String password)
451 throws IOException {
452
453 return getHttp().URLtoString(
454 location, host, port, realm, username, password);
455 }
456
457
467 public static String URLtoString(URL url) throws IOException {
468 return getHttp().URLtoString(url);
469 }
470
471 public void setHttp(Http http) {
472 _http = http;
473 }
474
475 private static Http _http;
476
477 }