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