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 void submit(String location) throws IOException;
133
134 public void submit(String location, Cookie[] cookies) throws IOException;
135
136 public void submit(String location, boolean post) throws IOException;
137
138 public void submit(String location, Cookie[] cookies, boolean post)
139 throws IOException;
140
141 public void submit(
142 String location, Cookie[] cookies, Http.Body body, boolean post)
143 throws IOException;
144
145 public void submit(
146 String location, Cookie[] cookies, Map<String, String> parts,
147 boolean post)
148 throws IOException;
149
150 public byte[] URLtoByteArray(String location) throws IOException;
151
152 public byte[] URLtoByteArray(String location, Cookie[] cookies)
153 throws IOException;
154
155 public byte[] URLtoByteArray(String location, boolean post)
156 throws IOException;
157
158 public byte[] URLtoByteArray(
159 String location, Cookie[] cookies, boolean post)
160 throws IOException;
161
162 public byte[] URLtoByteArray(
163 String location, Cookie[] cookies, Http.Body body, boolean post)
164 throws IOException;
165
166 public byte[] URLtoByteArray(
167 String location, Cookie[] cookies, Map<String, String> parts,
168 boolean post)
169 throws IOException;
170
171 public String URLtoString(String location) throws IOException;
172
173 public String URLtoString(String location, Cookie[] cookies)
174 throws IOException;
175
176 public String URLtoString(String location, boolean post) throws IOException;
177
178 public String URLtoString(
179 String location, Cookie[] cookies, boolean post)
180 throws IOException;
181
182 public String URLtoString(
183 String location, Cookie[] cookies, Http.Body body, boolean post)
184 throws IOException;
185
186 public String URLtoString(
187 String location, Cookie[] cookies, Map<String, String> parts,
188 boolean post)
189 throws IOException;
190
191 public String URLtoString(
192 String location, String host, int port, String realm,
193 String username, String password)
194 throws IOException;
195
196
207 public String URLtoString(URL url) throws IOException;
208
209 public class Body {
210
211 public Body(String content, String contentType, String charset) {
212 _content = content;
213 _contentType = contentType;
214 _charset = charset;
215 }
216
217 public String getContent() {
218 return _content;
219 }
220
221 public String getContentType() {
222 return _contentType;
223 }
224
225 public String getCharset() {
226 return _charset;
227 }
228
229 private String _content;
230 private String _contentType;
231 private String _charset;
232
233 }
234
235 }