Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/Response.java @ 974:7422ca1ae146
remove Connection.isIdle()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 15 Oct 2016 23:27:08 -0600 |
parents | 5ee36654b383 |
children | d35b0a3a7a4a |
rev | line source |
---|---|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
2 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
4 // ------------------------------------------------------------------------ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
5 // All rights reserved. This program and the accompanying materials |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
6 // are made available under the terms of the Eclipse Public License v1.0 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
7 // and Apache License v2.0 which accompanies this distribution. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
8 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
9 // The Eclipse Public License is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
10 // http://www.eclipse.org/legal/epl-v10.html |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
11 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
12 // The Apache License v2.0 is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
13 // http://www.opensource.org/licenses/apache2.0.php |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
14 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
15 // You may elect to redistribute this code under either of these licenses. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
16 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
17 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
18 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
19 package org.eclipse.jetty.server; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
20 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
21 import java.io.IOException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 import java.io.PrintWriter; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import java.util.Collection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 import java.util.ArrayList; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import java.util.Collections; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import java.util.EnumSet; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import java.util.Enumeration; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import java.util.Locale; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import javax.servlet.RequestDispatcher; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 import javax.servlet.ServletOutputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import javax.servlet.SessionTrackingMode; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 import javax.servlet.http.Cookie; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 import javax.servlet.http.HttpServletResponse; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 import javax.servlet.http.HttpSession; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 import org.eclipse.jetty.http.HttpCookie; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 import org.eclipse.jetty.http.HttpFields; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 import org.eclipse.jetty.http.HttpGenerator; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
40 import org.eclipse.jetty.http.HttpHeaderValues; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 import org.eclipse.jetty.http.HttpHeaders; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
42 import org.eclipse.jetty.http.HttpSchemes; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
43 import org.eclipse.jetty.http.HttpStatus; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
44 import org.eclipse.jetty.http.HttpURI; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
45 import org.eclipse.jetty.http.HttpVersions; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
46 import org.eclipse.jetty.http.MimeTypes; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
47 import org.eclipse.jetty.io.BufferCache.CachedBuffer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
48 import org.eclipse.jetty.server.handler.ContextHandler; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 import org.eclipse.jetty.util.ByteArrayISO8859Writer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
50 import org.eclipse.jetty.util.QuotedStringTokenizer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 import org.eclipse.jetty.util.StringUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
52 import org.eclipse.jetty.util.URIUtil; |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
813
diff
changeset
|
53 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
813
diff
changeset
|
54 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
55 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
56 /** Response. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
57 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
58 * Implements {@link javax.servlet.http.HttpServletResponse} from the <code>javax.servlet.http</code> package. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
59 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
60 */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
61 public class Response implements HttpServletResponse |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
62 { |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
813
diff
changeset
|
63 private static final Logger LOG = LoggerFactory.getLogger(Response.class); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
64 |
813 | 65 |
66 public static final int | |
67 NONE=0, | |
68 STREAM=1, | |
69 WRITER=2; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
70 |
813 | 71 /** |
72 * If a header name starts with this string, the header (stripped of the prefix) | |
73 * can be set during include using only {@link #setHeader(String, String)} or | |
74 * {@link #addHeader(String, String)}. | |
75 */ | |
76 public final static String SET_INCLUDE_HEADER_PREFIX = "org.eclipse.jetty.server.include."; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
77 |
813 | 78 /** |
79 * If this string is found within the comment of a cookie added with {@link #addCookie(Cookie)}, then the cookie | |
80 * will be set as HTTP ONLY. | |
81 */ | |
82 public final static String HTTP_ONLY_COMMENT="__HTTP_ONLY__"; | |
83 | |
84 | |
85 public static Response getResponse(HttpServletResponse response) | |
86 { | |
87 if (response instanceof Response) | |
88 return (Response)response; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
89 |
813 | 90 return AbstractHttpConnection.getCurrentConnection().getResponse(); |
91 } | |
92 | |
93 private final AbstractHttpConnection _connection; | |
94 private int _status=SC_OK; | |
95 private String _reason; | |
96 private Locale _locale; | |
97 private String _mimeType; | |
98 private CachedBuffer _cachedMimeType; | |
99 private String _characterEncoding; | |
100 private boolean _explicitEncoding; | |
101 private String _contentType; | |
102 private volatile int _outputState; | |
103 private PrintWriter _writer; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
104 |
813 | 105 /* ------------------------------------------------------------ */ |
106 /** | |
107 * | |
108 */ | |
109 public Response(AbstractHttpConnection connection) | |
110 { | |
111 _connection=connection; | |
112 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
113 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
114 |
813 | 115 /* ------------------------------------------------------------ */ |
116 /* | |
117 * @see javax.servlet.ServletResponse#reset() | |
118 */ | |
119 protected void recycle() | |
120 { | |
121 _status=SC_OK; | |
122 _reason=null; | |
123 _locale=null; | |
124 _mimeType=null; | |
125 _cachedMimeType=null; | |
126 _characterEncoding=null; | |
127 _explicitEncoding=false; | |
128 _contentType=null; | |
129 _writer=null; | |
130 _outputState=NONE; | |
131 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
132 |
813 | 133 /* ------------------------------------------------------------ */ |
134 /* | |
135 * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie) | |
136 */ | |
137 public void addCookie(HttpCookie cookie) | |
138 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
139 _connection._responseFields.addSetCookie(cookie); |
813 | 140 } |
141 | |
142 /* ------------------------------------------------------------ */ | |
143 /* | |
144 * @see javax.servlet.http.HttpServletResponse#addCookie(javax.servlet.http.Cookie) | |
145 */ | |
146 public void addCookie(Cookie cookie) | |
147 { | |
148 String comment=cookie.getComment(); | |
149 boolean http_only=false; | |
150 | |
151 if (comment!=null) | |
152 { | |
153 int i=comment.indexOf(HTTP_ONLY_COMMENT); | |
154 if (i>=0) | |
155 { | |
156 http_only=true; | |
157 comment=comment.replace(HTTP_ONLY_COMMENT,"").trim(); | |
158 if (comment.length()==0) | |
159 comment=null; | |
160 } | |
161 } | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
162 _connection._responseFields.addSetCookie(cookie.getName(), |
813 | 163 cookie.getValue(), |
164 cookie.getDomain(), | |
165 cookie.getPath(), | |
166 cookie.getMaxAge(), | |
167 comment, | |
168 cookie.getSecure(), | |
169 http_only || cookie.isHttpOnly(), | |
170 cookie.getVersion()); | |
171 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
172 |
813 | 173 /* ------------------------------------------------------------ */ |
174 /* | |
175 * @see javax.servlet.http.HttpServletResponse#containsHeader(java.lang.String) | |
176 */ | |
177 public boolean containsHeader(String name) | |
178 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
179 return _connection._responseFields.containsKey(name); |
813 | 180 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
181 |
813 | 182 /* ------------------------------------------------------------ */ |
183 /* | |
184 * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String) | |
185 */ | |
186 public String encodeURL(String url) | |
187 { | |
809
09d518d313b7
remove SessionManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
188 throw new UnsupportedOperationException(); |
813 | 189 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
190 |
813 | 191 /* ------------------------------------------------------------ */ |
192 /** | |
193 * @see javax.servlet.http.HttpServletResponse#encodeRedirectURL(java.lang.String) | |
194 */ | |
195 public String encodeRedirectURL(String url) | |
196 { | |
197 return encodeURL(url); | |
198 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
199 |
813 | 200 /* ------------------------------------------------------------ */ |
201 @Deprecated | |
202 public String encodeUrl(String url) | |
203 { | |
204 return encodeURL(url); | |
205 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
206 |
813 | 207 /* ------------------------------------------------------------ */ |
208 @Deprecated | |
209 public String encodeRedirectUrl(String url) | |
210 { | |
211 return encodeRedirectURL(url); | |
212 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
213 |
813 | 214 /* ------------------------------------------------------------ */ |
215 /* | |
216 * @see javax.servlet.http.HttpServletResponse#sendError(int, java.lang.String) | |
217 */ | |
218 public void sendError(int code, String message) throws IOException | |
219 { | |
220 if (isCommitted()) | |
221 LOG.warn("Committed before "+code+" "+message); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
222 |
813 | 223 resetBuffer(); |
224 _characterEncoding=null; | |
225 setHeader(HttpHeaders.EXPIRES,null); | |
226 setHeader(HttpHeaders.LAST_MODIFIED,null); | |
227 setHeader(HttpHeaders.CACHE_CONTROL,null); | |
228 setHeader(HttpHeaders.CONTENT_TYPE,null); | |
229 setHeader(HttpHeaders.CONTENT_LENGTH,null); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
230 |
813 | 231 _outputState=NONE; |
232 setStatus(code,message); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
233 |
813 | 234 if (message==null) |
235 message=HttpStatus.getMessage(code); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
236 |
813 | 237 // If we are allowed to have a body |
238 if (code!=SC_NO_CONTENT && | |
239 code!=SC_NOT_MODIFIED && | |
240 code!=SC_PARTIAL_CONTENT && | |
241 code>=SC_OK) | |
242 { | |
243 Request request = _connection.getRequest(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
244 |
911 | 245 setHeader(HttpHeaders.CACHE_CONTROL, "must-revalidate,no-cache,no-store"); |
246 setContentType(MimeTypes.TEXT_HTML_8859_1); | |
247 ByteArrayISO8859Writer writer= new ByteArrayISO8859Writer(2048); | |
248 if (message != null) | |
813 | 249 { |
911 | 250 message= StringUtil.replace(message, "&", "&"); |
251 message= StringUtil.replace(message, "<", "<"); | |
252 message= StringUtil.replace(message, ">", ">"); | |
813 | 253 } |
911 | 254 String uri= request.getRequestURI(); |
255 if (uri!=null) | |
813 | 256 { |
911 | 257 uri= StringUtil.replace(uri, "&", "&"); |
258 uri= StringUtil.replace(uri, "<", "<"); | |
259 uri= StringUtil.replace(uri, ">", ">"); | |
260 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
261 |
911 | 262 writer.write("<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=ISO-8859-1\"/>\n"); |
263 writer.write("<title>Error "); | |
264 writer.write(Integer.toString(code)); | |
265 writer.write(' '); | |
266 if (message==null) | |
267 message=HttpStatus.getMessage(code); | |
268 writer.write(message); | |
269 writer.write("</title>\n</head>\n<body>\n<h2>HTTP ERROR: "); | |
270 writer.write(Integer.toString(code)); | |
271 writer.write("</h2>\n<p>Problem accessing "); | |
272 writer.write(uri); | |
273 writer.write(". Reason:\n<pre> "); | |
274 writer.write(message); | |
275 writer.write("</pre>"); | |
276 writer.write("</p>\n<hr /><i><small>Powered by Jetty://</small></i>"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
277 |
911 | 278 for (int i= 0; i < 20; i++) |
279 writer.write("\n "); | |
280 writer.write("\n</body>\n</html>\n"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
281 |
911 | 282 writer.flush(); |
283 setContentLength(writer.size()); | |
284 writer.writeTo(getOutputStream()); | |
285 writer.destroy(); | |
813 | 286 } |
287 else if (code!=SC_PARTIAL_CONTENT) | |
288 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
289 _connection._requestFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER); |
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
290 _connection._requestFields.remove(HttpHeaders.CONTENT_LENGTH_BUFFER); |
813 | 291 _characterEncoding=null; |
292 _mimeType=null; | |
293 _cachedMimeType=null; | |
294 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
295 |
813 | 296 complete(); |
297 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
298 |
813 | 299 /* ------------------------------------------------------------ */ |
300 /* | |
301 * @see javax.servlet.http.HttpServletResponse#sendError(int) | |
302 */ | |
303 public void sendError(int sc) throws IOException | |
304 { | |
305 if (sc==102) | |
306 sendProcessing(); | |
307 else | |
308 sendError(sc,null); | |
309 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
310 |
813 | 311 /* ------------------------------------------------------------ */ |
312 /* Send a 102-Processing response. | |
313 * If the connection is a HTTP connection, the version is 1.1 and the | |
314 * request has a Expect header starting with 102, then a 102 response is | |
315 * sent. This indicates that the request still be processed and real response | |
316 * can still be sent. This method is called by sendError if it is passed 102. | |
317 * @see javax.servlet.http.HttpServletResponse#sendError(int) | |
318 */ | |
319 public void sendProcessing() throws IOException | |
320 { | |
321 if (_connection.isExpecting102Processing() && !isCommitted()) | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
322 _connection._generator.send1xx(HttpStatus.PROCESSING_102); |
813 | 323 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
324 |
813 | 325 /* ------------------------------------------------------------ */ |
326 /* | |
327 * @see javax.servlet.http.HttpServletResponse#sendRedirect(java.lang.String) | |
328 */ | |
329 public void sendRedirect(String location) throws IOException | |
330 { | |
331 if (location==null) | |
332 throw new IllegalArgumentException(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
333 |
813 | 334 if (!URIUtil.hasScheme(location)) |
335 { | |
336 StringBuilder buf = _connection.getRequest().getRootURL(); | |
337 if (location.startsWith("/")) | |
338 buf.append(location); | |
339 else | |
340 { | |
341 String path=_connection.getRequest().getRequestURI(); | |
342 String parent=(path.endsWith("/"))?path:URIUtil.parentPath(path); | |
343 location=URIUtil.addPaths(parent,location); | |
344 if(location==null) | |
345 throw new IllegalStateException("path cannot be above root"); | |
346 if (!location.startsWith("/")) | |
347 buf.append('/'); | |
348 buf.append(location); | |
349 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
350 |
813 | 351 location=buf.toString(); |
352 HttpURI uri = new HttpURI(location); | |
353 String path=uri.getDecodedPath(); | |
354 String canonical=URIUtil.canonicalPath(path); | |
355 if (canonical==null) | |
356 throw new IllegalArgumentException(); | |
357 if (!canonical.equals(path)) | |
358 { | |
359 buf = _connection.getRequest().getRootURL(); | |
360 buf.append(URIUtil.encodePath(canonical)); | |
361 String param=uri.getParam(); | |
362 if (param!=null) | |
363 { | |
364 buf.append(';'); | |
365 buf.append(param); | |
366 } | |
367 String query=uri.getQuery(); | |
368 if (query!=null) | |
369 { | |
370 buf.append('?'); | |
371 buf.append(query); | |
372 } | |
373 String fragment=uri.getFragment(); | |
374 if (fragment!=null) | |
375 { | |
376 buf.append('#'); | |
377 buf.append(fragment); | |
378 } | |
379 location=buf.toString(); | |
380 } | |
381 } | |
382 | |
383 resetBuffer(); | |
384 setHeader(HttpHeaders.LOCATION,location); | |
385 setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); | |
386 complete(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
387 |
813 | 388 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
389 |
813 | 390 /* ------------------------------------------------------------ */ |
391 /* | |
392 * @see javax.servlet.http.HttpServletResponse#setDateHeader(java.lang.String, long) | |
393 */ | |
394 public void setDateHeader(String name, long date) | |
395 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
396 _connection._responseFields.putDateField(name, date); |
813 | 397 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
398 |
813 | 399 /* ------------------------------------------------------------ */ |
400 /* | |
401 * @see javax.servlet.http.HttpServletResponse#addDateHeader(java.lang.String, long) | |
402 */ | |
403 public void addDateHeader(String name, long date) | |
404 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
405 _connection._responseFields.addDateField(name, date); |
813 | 406 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
407 |
813 | 408 /* ------------------------------------------------------------ */ |
409 /* | |
410 * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, java.lang.String) | |
411 */ | |
412 public void setHeader(String name, String value) | |
413 { | |
414 if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) | |
415 setContentType(value); | |
416 else | |
417 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
418 _connection._responseFields.put(name, value); |
813 | 419 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) |
420 { | |
421 if (value==null) | |
422 _connection._generator.setContentLength(-1); | |
423 else | |
424 _connection._generator.setContentLength(Long.parseLong(value)); | |
425 } | |
426 } | |
427 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
428 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
429 |
813 | 430 /* ------------------------------------------------------------ */ |
431 public Collection<String> getHeaderNames() | |
432 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
433 final HttpFields fields=_connection._responseFields; |
813 | 434 return fields.getFieldNamesCollection(); |
435 } | |
436 | |
437 /* ------------------------------------------------------------ */ | |
438 /* | |
439 */ | |
440 public String getHeader(String name) | |
441 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
442 return _connection._responseFields.getStringField(name); |
813 | 443 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
444 |
813 | 445 /* ------------------------------------------------------------ */ |
446 /* | |
447 */ | |
448 public Collection<String> getHeaders(String name) | |
449 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
450 final HttpFields fields=_connection._responseFields; |
813 | 451 Collection<String> i = fields.getValuesCollection(name); |
452 if (i==null) | |
453 return Collections.EMPTY_LIST; | |
454 return i; | |
455 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
456 |
813 | 457 /* ------------------------------------------------------------ */ |
458 /* | |
459 * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, java.lang.String) | |
460 */ | |
461 public void addHeader(String name, String value) | |
462 { | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
463 |
813 | 464 if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) |
465 { | |
466 setContentType(value); | |
467 return; | |
468 } | |
469 | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
470 _connection._responseFields.add(name, value); |
813 | 471 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) |
472 _connection._generator.setContentLength(Long.parseLong(value)); | |
473 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
474 |
813 | 475 /* ------------------------------------------------------------ */ |
476 /* | |
477 * @see javax.servlet.http.HttpServletResponse#setIntHeader(java.lang.String, int) | |
478 */ | |
479 public void setIntHeader(String name, int value) | |
480 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
481 _connection._responseFields.putLongField(name, value); |
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
482 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) |
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
483 _connection._generator.setContentLength(value); |
813 | 484 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
485 |
813 | 486 /* ------------------------------------------------------------ */ |
487 /* | |
488 * @see javax.servlet.http.HttpServletResponse#addIntHeader(java.lang.String, int) | |
489 */ | |
490 public void addIntHeader(String name, int value) | |
491 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
492 _connection._responseFields.addLongField(name, value); |
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
493 if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) |
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
494 _connection._generator.setContentLength(value); |
813 | 495 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
496 |
813 | 497 /* ------------------------------------------------------------ */ |
498 /* | |
499 * @see javax.servlet.http.HttpServletResponse#setStatus(int) | |
500 */ | |
501 public void setStatus(int sc) | |
502 { | |
503 setStatus(sc,null); | |
504 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
505 |
813 | 506 /* ------------------------------------------------------------ */ |
507 /* | |
508 * @see javax.servlet.http.HttpServletResponse#setStatus(int, java.lang.String) | |
509 */ | |
510 public void setStatus(int sc, String sm) | |
511 { | |
512 if (sc<=0) | |
513 throw new IllegalArgumentException(); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
514 _status=sc; |
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
515 _reason=sm; |
813 | 516 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
517 |
813 | 518 /* ------------------------------------------------------------ */ |
519 /* | |
520 * @see javax.servlet.ServletResponse#getCharacterEncoding() | |
521 */ | |
522 public String getCharacterEncoding() | |
523 { | |
524 if (_characterEncoding==null) | |
525 _characterEncoding=StringUtil.__ISO_8859_1; | |
526 return _characterEncoding; | |
527 } | |
528 | |
529 /* ------------------------------------------------------------ */ | |
530 String getSetCharacterEncoding() | |
531 { | |
532 return _characterEncoding; | |
533 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
534 |
813 | 535 /* ------------------------------------------------------------ */ |
536 /* | |
537 * @see javax.servlet.ServletResponse#getContentType() | |
538 */ | |
539 public String getContentType() | |
540 { | |
541 return _contentType; | |
542 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
543 |
813 | 544 /* ------------------------------------------------------------ */ |
545 /* | |
546 * @see javax.servlet.ServletResponse#getOutputStream() | |
547 */ | |
548 public ServletOutputStream getOutputStream() throws IOException | |
549 { | |
550 if (_outputState!=NONE && _outputState!=STREAM) | |
551 throw new IllegalStateException("WRITER"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
552 |
813 | 553 ServletOutputStream out = _connection.getOutputStream(); |
554 _outputState=STREAM; | |
555 return out; | |
556 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
557 |
813 | 558 /* ------------------------------------------------------------ */ |
559 public boolean isWriting() | |
560 { | |
561 return _outputState==WRITER; | |
562 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
563 |
813 | 564 /* ------------------------------------------------------------ */ |
565 public boolean isOutputing() | |
566 { | |
567 return _outputState!=NONE; | |
568 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
569 |
813 | 570 /* ------------------------------------------------------------ */ |
571 /* | |
572 * @see javax.servlet.ServletResponse#getWriter() | |
573 */ | |
574 public PrintWriter getWriter() throws IOException | |
575 { | |
576 if (_outputState!=NONE && _outputState!=WRITER) | |
577 throw new IllegalStateException("STREAM"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
578 |
813 | 579 /* if there is no writer yet */ |
580 if (_writer==null) | |
581 { | |
582 /* get encoding from Content-Type header */ | |
583 String encoding = _characterEncoding; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
584 |
813 | 585 if (encoding==null) |
586 { | |
587 /* implementation of educated defaults */ | |
588 if(_cachedMimeType != null) | |
589 encoding = MimeTypes.getCharsetFromContentType(_cachedMimeType); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
590 |
813 | 591 if (encoding==null) |
592 encoding = StringUtil.__ISO_8859_1; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
593 |
813 | 594 setCharacterEncoding(encoding); |
595 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
596 |
813 | 597 /* construct Writer using correct encoding */ |
598 _writer = _connection.getPrintWriter(encoding); | |
599 } | |
600 _outputState=WRITER; | |
601 return _writer; | |
602 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
603 |
813 | 604 /* ------------------------------------------------------------ */ |
605 /* | |
606 * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String) | |
607 */ | |
608 public void setCharacterEncoding(String encoding) | |
609 { | |
610 if (this._outputState==0 && !isCommitted()) | |
611 { | |
612 _explicitEncoding=true; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
613 |
813 | 614 if (encoding==null) |
615 { | |
616 // Clear any encoding. | |
617 if (_characterEncoding!=null) | |
618 { | |
619 _characterEncoding=null; | |
620 if (_cachedMimeType!=null) | |
621 _contentType=_cachedMimeType.toString(); | |
622 else if (_mimeType!=null) | |
623 _contentType=_mimeType; | |
624 else | |
625 _contentType=null; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
626 |
813 | 627 if (_contentType==null) |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
628 _connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER); |
813 | 629 else |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
630 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 631 } |
632 } | |
633 else | |
634 { | |
635 // No, so just add this one to the mimetype | |
636 _characterEncoding=encoding; | |
637 if (_contentType!=null) | |
638 { | |
639 int i0=_contentType.indexOf(';'); | |
640 if (i0<0) | |
641 { | |
642 _contentType=null; | |
643 if(_cachedMimeType!=null) | |
644 { | |
645 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding); | |
646 if (content_type!=null) | |
647 { | |
648 _contentType=content_type.toString(); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
649 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); |
813 | 650 } |
651 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
652 |
813 | 653 if (_contentType==null) |
654 { | |
655 _contentType = _mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
656 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 657 } |
658 } | |
659 else | |
660 { | |
661 int i1=_contentType.indexOf("charset=",i0); | |
662 if (i1<0) | |
663 { | |
664 _contentType = _contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
665 } | |
666 else | |
667 { | |
668 int i8=i1+8; | |
669 int i2=_contentType.indexOf(" ",i8); | |
670 if (i2<0) | |
671 _contentType=_contentType.substring(0,i8)+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
672 else | |
673 _contentType=_contentType.substring(0,i8)+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ")+_contentType.substring(i2); | |
674 } | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
675 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 676 } |
677 } | |
678 } | |
679 } | |
680 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
681 |
813 | 682 /* ------------------------------------------------------------ */ |
683 /* | |
684 * @see javax.servlet.ServletResponse#setContentLength(int) | |
685 */ | |
686 public void setContentLength(int len) | |
687 { | |
688 // Protect from setting after committed as default handling | |
689 // of a servlet HEAD request ALWAYS sets _content length, even | |
690 // if the getHandling committed the response! | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
691 if (isCommitted()) |
813 | 692 return; |
693 _connection._generator.setContentLength(len); | |
694 if (len>0) | |
695 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
696 _connection._responseFields.putLongField(HttpHeaders.CONTENT_LENGTH, len); |
813 | 697 if (_connection._generator.isAllContentWritten()) |
698 { | |
699 if (_outputState==WRITER) | |
700 _writer.close(); | |
701 else if (_outputState==STREAM) | |
702 { | |
703 try | |
704 { | |
705 getOutputStream().close(); | |
706 } | |
707 catch(IOException e) | |
708 { | |
709 throw new RuntimeException(e); | |
710 } | |
711 } | |
712 } | |
713 } | |
714 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
715 |
813 | 716 /* ------------------------------------------------------------ */ |
717 /* | |
718 * @see javax.servlet.ServletResponse#setContentLength(int) | |
719 */ | |
720 public void setLongContentLength(long len) | |
721 { | |
722 // Protect from setting after committed as default handling | |
723 // of a servlet HEAD request ALWAYS sets _content length, even | |
724 // if the getHandling committed the response! | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
725 if (isCommitted()) |
813 | 726 return; |
727 _connection._generator.setContentLength(len); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
728 _connection._responseFields.putLongField(HttpHeaders.CONTENT_LENGTH, len); |
813 | 729 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
730 |
813 | 731 /* ------------------------------------------------------------ */ |
732 /* | |
733 * @see javax.servlet.ServletResponse#setContentType(java.lang.String) | |
734 */ | |
735 public void setContentType(String contentType) | |
736 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
737 if (isCommitted()) |
813 | 738 return; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
739 |
813 | 740 // Yes this method is horribly complex.... but there are lots of special cases and |
741 // as this method is called on every request, it is worth trying to save string creation. | |
742 // | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
743 |
813 | 744 if (contentType==null) |
745 { | |
746 if (_locale==null) | |
747 _characterEncoding=null; | |
748 _mimeType=null; | |
749 _cachedMimeType=null; | |
750 _contentType=null; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
751 _connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER); |
813 | 752 } |
753 else | |
754 { | |
755 // Look for encoding in contentType | |
756 int i0=contentType.indexOf(';'); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
757 |
813 | 758 if (i0>0) |
759 { | |
760 // we have content type parameters | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
761 |
813 | 762 // Extract params off mimetype |
763 _mimeType=contentType.substring(0,i0).trim(); | |
764 _cachedMimeType=MimeTypes.CACHE.get(_mimeType); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
765 |
813 | 766 // Look for charset |
767 int i1=contentType.indexOf("charset=",i0+1); | |
768 if (i1>=0) | |
769 { | |
770 _explicitEncoding=true; | |
771 int i8=i1+8; | |
772 int i2 = contentType.indexOf(' ',i8); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
773 |
813 | 774 if (_outputState==WRITER) |
775 { | |
776 // strip the charset and ignore; | |
777 if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' ')) | |
778 { | |
779 if (_cachedMimeType!=null) | |
780 { | |
781 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding); | |
782 if (content_type!=null) | |
783 { | |
784 _contentType=content_type.toString(); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
785 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); |
813 | 786 } |
787 else | |
788 { | |
789 _contentType=_mimeType+";charset="+_characterEncoding; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
790 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 791 } |
792 } | |
793 else | |
794 { | |
795 _contentType=_mimeType+";charset="+_characterEncoding; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
796 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 797 } |
798 } | |
799 else if (i2<0) | |
800 { | |
801 _contentType=contentType.substring(0,i1)+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
802 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 803 } |
804 else | |
805 { | |
806 _contentType=contentType.substring(0,i1)+contentType.substring(i2)+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
807 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 808 } |
809 } | |
810 else if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' ')) | |
811 { | |
812 // The params are just the char encoding | |
813 _cachedMimeType=MimeTypes.CACHE.get(_mimeType); | |
814 _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8)); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
815 |
813 | 816 if (_cachedMimeType!=null) |
817 { | |
818 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding); | |
819 if (content_type!=null) | |
820 { | |
821 _contentType=content_type.toString(); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
822 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); |
813 | 823 } |
824 else | |
825 { | |
826 _contentType=contentType; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
827 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 828 } |
829 } | |
830 else | |
831 { | |
832 _contentType=contentType; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
833 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 834 } |
835 } | |
836 else if (i2>0) | |
837 { | |
838 _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8,i2)); | |
839 _contentType=contentType; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
840 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 841 } |
842 else | |
843 { | |
844 _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8)); | |
845 _contentType=contentType; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
846 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 847 } |
848 } | |
849 else // No encoding in the params. | |
850 { | |
851 _cachedMimeType=null; | |
852 _contentType=_characterEncoding==null?contentType:contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
853 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 854 } |
855 } | |
856 else // No params at all | |
857 { | |
858 _mimeType=contentType; | |
859 _cachedMimeType=MimeTypes.CACHE.get(_mimeType); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
860 |
813 | 861 if (_characterEncoding!=null) |
862 { | |
863 if (_cachedMimeType!=null) | |
864 { | |
865 CachedBuffer content_type = _cachedMimeType.getAssociate(_characterEncoding); | |
866 if (content_type!=null) | |
867 { | |
868 _contentType=content_type.toString(); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
869 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); |
813 | 870 } |
871 else | |
872 { | |
873 _contentType=_mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
874 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 875 } |
876 } | |
877 else | |
878 { | |
879 _contentType=contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
880 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 881 } |
882 } | |
883 else if (_cachedMimeType!=null) | |
884 { | |
885 _contentType=_cachedMimeType.toString(); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
886 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_cachedMimeType); |
813 | 887 } |
888 else | |
889 { | |
890 _contentType=contentType; | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
891 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 892 } |
893 } | |
894 } | |
895 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
896 |
813 | 897 /* ------------------------------------------------------------ */ |
898 /* | |
899 * @see javax.servlet.ServletResponse#setBufferSize(int) | |
900 */ | |
901 public void setBufferSize(int size) | |
902 { | |
903 if (isCommitted() || getContentCount()>0) | |
904 throw new IllegalStateException("Committed or content written"); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
905 _connection._generator.increaseContentBufferSize(size); |
813 | 906 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
907 |
813 | 908 /* ------------------------------------------------------------ */ |
909 /* | |
910 * @see javax.servlet.ServletResponse#getBufferSize() | |
911 */ | |
912 public int getBufferSize() | |
913 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
914 return _connection._generator.getContentBufferSize(); |
813 | 915 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
916 |
813 | 917 /* ------------------------------------------------------------ */ |
918 /* | |
919 * @see javax.servlet.ServletResponse#flushBuffer() | |
920 */ | |
921 public void flushBuffer() throws IOException | |
922 { | |
923 _connection.flushResponse(); | |
924 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
925 |
813 | 926 /* ------------------------------------------------------------ */ |
927 /* | |
928 * @see javax.servlet.ServletResponse#reset() | |
929 */ | |
930 public void reset() | |
931 { | |
932 resetBuffer(); | |
933 fwdReset(); | |
934 _status=200; | |
935 _reason=null; | |
936 | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
937 HttpFields response_fields=_connection._responseFields; |
813 | 938 |
939 response_fields.clear(); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
940 String connection=_connection._requestFields.getStringField(HttpHeaders.CONNECTION_BUFFER); |
813 | 941 if (connection!=null) |
942 { | |
943 String[] values = connection.split(","); | |
944 for (int i=0;values!=null && i<values.length;i++) | |
945 { | |
946 CachedBuffer cb = HttpHeaderValues.CACHE.get(values[0].trim()); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
947 |
813 | 948 if (cb!=null) |
949 { | |
950 switch(cb.getOrdinal()) | |
951 { | |
952 case HttpHeaderValues.CLOSE_ORDINAL: | |
953 response_fields.put(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.CLOSE_BUFFER); | |
954 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
955 |
813 | 956 case HttpHeaderValues.KEEP_ALIVE_ORDINAL: |
957 if (HttpVersions.HTTP_1_0.equalsIgnoreCase(_connection.getRequest().getProtocol())) | |
958 response_fields.put(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.KEEP_ALIVE); | |
959 break; | |
960 case HttpHeaderValues.TE_ORDINAL: | |
961 response_fields.put(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.TE); | |
962 break; | |
963 } | |
964 } | |
965 } | |
966 } | |
967 } | |
968 | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
969 |
813 | 970 public void reset(boolean preserveCookies) |
971 { | |
972 if (!preserveCookies) | |
973 reset(); | |
974 else | |
975 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
976 HttpFields response_fields=_connection._responseFields; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
977 |
813 | 978 ArrayList<String> cookieValues = new ArrayList<String>(5); |
979 Enumeration<String> vals = response_fields.getValues(HttpHeaders.SET_COOKIE); | |
980 while (vals.hasMoreElements()) | |
981 cookieValues.add((String)vals.nextElement()); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
982 |
813 | 983 reset(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
984 |
813 | 985 for (String v:cookieValues) |
986 response_fields.add(HttpHeaders.SET_COOKIE, v); | |
987 } | |
988 } | |
989 | |
990 | |
991 | |
992 /* ------------------------------------------------------------ */ | |
993 /* | |
994 * @see javax.servlet.ServletResponse#reset() | |
995 */ | |
996 public void fwdReset() | |
997 { | |
998 resetBuffer(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
999 |
813 | 1000 _writer=null; |
1001 _outputState=NONE; | |
1002 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1003 |
813 | 1004 /* ------------------------------------------------------------ */ |
1005 /* | |
1006 * @see javax.servlet.ServletResponse#resetBuffer() | |
1007 */ | |
1008 public void resetBuffer() | |
1009 { | |
1010 if (isCommitted()) | |
1011 throw new IllegalStateException("Committed"); | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1012 _connection._generator.resetBuffer(); |
813 | 1013 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1014 |
813 | 1015 /* ------------------------------------------------------------ */ |
1016 /* | |
1017 * @see javax.servlet.ServletResponse#isCommitted() | |
1018 */ | |
1019 public boolean isCommitted() | |
1020 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1021 return _connection._generator.isCommitted(); |
813 | 1022 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1023 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1024 |
813 | 1025 /* ------------------------------------------------------------ */ |
1026 /* | |
1027 * @see javax.servlet.ServletResponse#setLocale(java.util.Locale) | |
1028 */ | |
1029 public void setLocale(Locale locale) | |
1030 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1031 if (locale == null || isCommitted()) |
813 | 1032 return; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1033 |
813 | 1034 _locale = locale; |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1035 _connection._responseFields.put(HttpHeaders.CONTENT_LANGUAGE_BUFFER,locale.toString().replace('_','-')); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1036 |
813 | 1037 if (_explicitEncoding || _outputState!=0 ) |
1038 return; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1039 |
813 | 1040 if (_connection.getRequest().getContext()==null) |
1041 return; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1042 |
813 | 1043 String charset = _connection.getRequest().getContext().getContextHandler().getLocaleEncoding(locale); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1044 |
813 | 1045 if (charset!=null && charset.length()>0) |
1046 { | |
1047 _characterEncoding=charset; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1048 |
813 | 1049 /* get current MIME type from Content-Type header */ |
1050 String type=getContentType(); | |
1051 if (type!=null) | |
1052 { | |
1053 _characterEncoding=charset; | |
1054 int semi=type.indexOf(';'); | |
1055 if (semi<0) | |
1056 { | |
1057 _mimeType=type; | |
1058 _contentType= type += ";charset="+charset; | |
1059 } | |
1060 else | |
1061 { | |
1062 _mimeType=type.substring(0,semi); | |
1063 _contentType= _mimeType += ";charset="+charset; | |
1064 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1065 |
813 | 1066 _cachedMimeType=MimeTypes.CACHE.get(_mimeType); |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1067 _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); |
813 | 1068 } |
1069 } | |
1070 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1071 |
813 | 1072 /* ------------------------------------------------------------ */ |
1073 /* | |
1074 * @see javax.servlet.ServletResponse#getLocale() | |
1075 */ | |
1076 public Locale getLocale() | |
1077 { | |
1078 if (_locale==null) | |
1079 return Locale.getDefault(); | |
1080 return _locale; | |
1081 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1082 |
813 | 1083 /* ------------------------------------------------------------ */ |
1084 /** | |
1085 * @return The HTTP status code that has been set for this request. This will be <code>200<code> | |
1086 * ({@link HttpServletResponse#SC_OK}), unless explicitly set through one of the <code>setStatus</code> methods. | |
1087 */ | |
1088 public int getStatus() | |
1089 { | |
1090 return _status; | |
1091 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1092 |
813 | 1093 /* ------------------------------------------------------------ */ |
1094 /** | |
1095 * @return The reason associated with the current {@link #getStatus() status}. This will be <code>null</code>, | |
1096 * unless one of the <code>setStatus</code> methods have been called. | |
1097 */ | |
1098 public String getReason() | |
1099 { | |
1100 return _reason; | |
1101 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1102 |
813 | 1103 /* ------------------------------------------------------------ */ |
1104 /** | |
1105 */ | |
1106 public void complete() | |
1107 throws IOException | |
1108 { | |
1109 _connection.completeResponse(); | |
1110 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1111 |
813 | 1112 /* ------------------------------------------------------------- */ |
1113 /** | |
1114 * @return the number of bytes actually written in response body | |
1115 */ | |
1116 public long getContentCount() | |
1117 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1118 if (_connection==null) |
813 | 1119 return -1; |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1120 return _connection._generator.getContentWritten(); |
813 | 1121 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1122 |
813 | 1123 /* ------------------------------------------------------------ */ |
1124 public HttpFields getHttpFields() | |
1125 { | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1126 return _connection._responseFields; |
813 | 1127 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1128 |
813 | 1129 /* ------------------------------------------------------------ */ |
1130 @Override | |
1131 public String toString() | |
1132 { | |
1133 return "HTTP/1.1 "+_status+" "+ (_reason==null?"":_reason) +System.getProperty("line.separator")+ | |
972
5ee36654b383
simplify AbstractHttpConnection
Franklin Schmidt <fschmidt@gmail.com>
parents:
911
diff
changeset
|
1134 _connection._responseFields.toString(); |
813 | 1135 } |
1136 | |
1137 /* ------------------------------------------------------------ */ | |
1138 /* ------------------------------------------------------------ */ | |
1139 /* ------------------------------------------------------------ */ | |
1140 private static class NullOutput extends ServletOutputStream | |
1141 { | |
1142 @Override | |
1143 public void write(int b) throws IOException | |
1144 { | |
1145 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1146 |
813 | 1147 @Override |
1148 public void print(String s) throws IOException | |
1149 { | |
1150 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1151 |
813 | 1152 @Override |
1153 public void println(String s) throws IOException | |
1154 { | |
1155 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1156 |
813 | 1157 @Override |
1158 public void write(byte[] b, int off, int len) throws IOException | |
1159 { | |
1160 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1161 |
813 | 1162 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1163 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1164 } |