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