1
19
20 package com.liferay.portal.kernel.util;
21
22 import java.io.IOException;
23
24 import java.net.URL;
25
26 import java.util.Map;
27
28 import javax.portlet.ActionRequest;
29 import javax.portlet.RenderRequest;
30
31 import javax.servlet.http.Cookie;
32 import javax.servlet.http.HttpServletRequest;
33
34
40 public interface Http {
41
42 public static final String HTTP = "http";
43
44 public static final String HTTPS = "https";
45
46 public static final String HTTP_WITH_SLASH = "http://";
47
48 public static final String HTTPS_WITH_SLASH = "https://";
49
50 public static final int HTTP_PORT = 80;
51
52 public static final int HTTPS_PORT = 443;
53
54 public static final String PROTOCOL_DELIMITER = "://";
55
56 public String addParameter(String url, String name, boolean value);
57
58 public String addParameter(String url, String name, double value);
59
60 public String addParameter(String url, String name, int value);
61
62 public String addParameter(String url, String name, long value);
63
64 public String addParameter(String url, String name, short value);
65
66 public String addParameter(String url, String name, String value);
67
68 public String decodeURL(String url);
69
70 public String decodeURL(String url, boolean unescapeSpace);
71
72 public String encodeURL(String url);
73
74 public String encodeURL(String url, boolean escapeSpaces);
75
76 public String getCompleteURL(HttpServletRequest request);
77
78 public String getDomain(String url);
79
80 public String getParameter(String url, String name);
81
82 public String getParameter(String url, String name, boolean escaped);
83
84 public Map<String, String[]> getParameterMap(String queryString);
85
86 public String getProtocol(boolean secure);
87
88 public String getProtocol(String url);
89
90 public String getProtocol(HttpServletRequest request);
91
92 public String getProtocol(ActionRequest actionRequest);
93
94 public String getProtocol(RenderRequest renderRequest);
95
96 public String getQueryString(String url);
97
98 public String getRequestURL(HttpServletRequest request);
99
100 public boolean hasDomain(String url);
101
102 public boolean hasProxyConfig();
103
104 public boolean isNonProxyHost(String host);
105
106 public boolean isProxyHost(String host);
107
108 public Map<String, String[]> parameterMapFromString(String queryString);
109
110 public String parameterMapToString(Map<String, String[]> parameterMap);
111
112 public String parameterMapToString(
113 Map<String, String[]> parameterMap, boolean addQuestion);
114
115 public String protocolize(String url, boolean secure);
116
117 public String protocolize(String url, HttpServletRequest request);
118
119 public String protocolize(String url, ActionRequest actionRequest);
120
121 public String protocolize(String url, RenderRequest renderRequest);
122
123 public String removeDomain(String url);
124
125 public String removeParameter(String url, String name);
126
127 public String removeProtocol(String url);
128
129 public String setParameter(String url, String name, boolean value);
130
131 public String setParameter(String url, String name, double value);
132
133 public String setParameter(String url, String name, int value);
134
135 public String setParameter(String url, String name, long value);
136
137 public String setParameter(String url, String name, short value);
138
139 public String setParameter(String url, String name, String value);
140
141 public void submit(String location) throws IOException;
142
143 public void submit(String location, Cookie[] cookies) throws IOException;
144
145 public void submit(String location, boolean post) throws IOException;
146
147 public void submit(String location, Cookie[] cookies, boolean post)
148 throws IOException;
149
150 public void submit(
151 String location, Cookie[] cookies, Http.Body body, boolean post)
152 throws IOException;
153
154 public void submit(
155 String location, Cookie[] cookies, Map<String, String> parts,
156 boolean post)
157 throws IOException;
158
159 public byte[] URLtoByteArray(String location) throws IOException;
160
161 public byte[] URLtoByteArray(String location, Cookie[] cookies)
162 throws IOException;
163
164 public byte[] URLtoByteArray(String location, boolean post)
165 throws IOException;
166
167 public byte[] URLtoByteArray(
168 String location, Cookie[] cookies, boolean post)
169 throws IOException;
170
171 public byte[] URLtoByteArray(
172 String location, Cookie[] cookies, Http.Body body, boolean post)
173 throws IOException;
174
175 public byte[] URLtoByteArray(
176 String location, Cookie[] cookies, Map<String, String> parts,
177 boolean post)
178 throws IOException;
179
180 public String URLtoString(String location) throws IOException;
181
182 public String URLtoString(String location, Cookie[] cookies)
183 throws IOException;
184
185 public String URLtoString(String location, boolean post) throws IOException;
186
187 public String URLtoString(
188 String location, Cookie[] cookies, boolean post)
189 throws IOException;
190
191 public String URLtoString(
192 String location, Cookie[] cookies, Http.Body body, boolean post)
193 throws IOException;
194
195 public String URLtoString(
196 String location, Cookie[] cookies, Map<String, String> parts,
197 boolean post)
198 throws IOException;
199
200 public String URLtoString(
201 String location, String host, int port, String realm,
202 String username, String password)
203 throws IOException;
204
205
216 public String URLtoString(URL url) throws IOException;
217
218 public class Body {
219
220 public Body(String content, String contentType, String charset) {
221 _content = content;
222 _contentType = contentType;
223 _charset = charset;
224 }
225
226 public String getContent() {
227 return _content;
228 }
229
230 public String getContentType() {
231 return _contentType;
232 }
233
234 public String getCharset() {
235 return _charset;
236 }
237
238 private String _content;
239 private String _contentType;
240 private String _charset;
241
242 }
243
244 }