Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/AbstractHttpConnection.java @ 884:cb78ee27b0e0
remove Server.getVersion()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 04 Oct 2016 16:30:02 -0600 |
parents | d850a5e6ff15 |
children | 150092cebf3e |
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.InputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import java.io.PrintWriter; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import javax.servlet.DispatcherType; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import javax.servlet.RequestDispatcher; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import javax.servlet.ServletInputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import javax.servlet.ServletOutputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 import javax.servlet.http.HttpServletRequest; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import javax.servlet.http.HttpServletResponse; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import org.eclipse.jetty.continuation.ContinuationThrowable; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 import org.eclipse.jetty.http.EncodedHttpURI; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 import org.eclipse.jetty.http.Generator; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 import org.eclipse.jetty.http.HttpBuffers; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 import org.eclipse.jetty.http.HttpException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 import org.eclipse.jetty.http.HttpFields; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 import org.eclipse.jetty.http.HttpGenerator; |
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.HttpMethods; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
42 import org.eclipse.jetty.http.HttpParser; |
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.http.Parser; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
48 import org.eclipse.jetty.io.AbstractConnection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 import org.eclipse.jetty.io.Buffer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
50 import org.eclipse.jetty.io.BufferCache.CachedBuffer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 import org.eclipse.jetty.io.Buffers; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
52 import org.eclipse.jetty.io.Connection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
53 import org.eclipse.jetty.io.EndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
54 import org.eclipse.jetty.io.EofException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
55 import org.eclipse.jetty.io.RuntimeIOException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
56 import org.eclipse.jetty.server.handler.ErrorHandler; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
57 import org.eclipse.jetty.server.nio.NIOConnector; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
58 import org.eclipse.jetty.server.ssl.SslConnector; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
59 import org.eclipse.jetty.util.QuotedStringTokenizer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
60 import org.eclipse.jetty.util.StringUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
61 import org.eclipse.jetty.util.URIUtil; |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
62 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
63 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
64 import org.eclipse.jetty.util.resource.Resource; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
65 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
66 /** |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
67 * <p>A HttpConnection represents the connection of a HTTP client to the server |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
68 * and is created by an instance of a {@link Connector}. It's prime function is |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
69 * to associate {@link Request} and {@link Response} instances with a {@link EndPoint}. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
70 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
71 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
72 * A connection is also the prime mechanism used by jetty to recycle objects without |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
73 * pooling. The {@link Request}, {@link Response}, {@link HttpParser}, {@link HttpGenerator} |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
74 * and {@link HttpFields} instances are all recycled for the duraction of |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
75 * a connection. Where appropriate, allocated buffers are also kept associated |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
76 * with the connection via the parser and/or generator. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
77 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
78 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
79 * The connection state is held by 3 separate state machines: The request state, the |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
80 * response state and the continuation state. All three state machines must be driven |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
81 * to completion for every request, and all three can complete in any order. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
82 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
83 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
84 * The HttpConnection support protocol upgrade. If on completion of a request, the |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
85 * response code is 101 (switch protocols), then the org.eclipse.jetty.io.Connection |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
86 * request attribute is checked to see if there is a new Connection instance. If so, |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
87 * the new connection is returned from {@link #handle()} and is used for future |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
88 * handling of the underlying connection. Note that for switching protocols that |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
89 * don't use 101 responses (eg CONNECT), the response should be sent and then the |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
90 * status code changed to 101 before returning from the handler. Implementors |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
91 * of new Connection types should be careful to extract any buffered data from |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
92 * (HttpParser)http.getParser()).getHeaderBuffer() and |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
93 * (HttpParser)http.getParser()).getBodyBuffer() to initialise their new connection. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
94 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
95 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
96 */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
97 public abstract class AbstractHttpConnection extends AbstractConnection |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
98 { |
826 | 99 private static final Logger LOG = LoggerFactory.getLogger(AbstractHttpConnection.class); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
100 |
826 | 101 private static final int UNKNOWN = -2; |
102 private static final ThreadLocal<AbstractHttpConnection> __currentConnection = new ThreadLocal<AbstractHttpConnection>(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
103 |
826 | 104 private int _requests; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
105 |
826 | 106 protected final Connector _connector; |
107 protected final Server _server; | |
108 protected final HttpURI _uri; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
109 |
826 | 110 protected final Parser _parser; |
111 protected final HttpFields _requestFields; | |
112 protected final Request _request; | |
113 protected volatile ServletInputStream _in; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
114 |
826 | 115 protected final Generator _generator; |
116 protected final HttpFields _responseFields; | |
117 protected final Response _response; | |
118 protected volatile Output _out; | |
119 protected volatile OutputWriter _writer; | |
120 protected volatile PrintWriter _printWriter; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
121 |
826 | 122 int _include; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
123 |
826 | 124 private Object _associatedObject; // associated object |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
125 |
826 | 126 private int _version = UNKNOWN; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
127 |
826 | 128 private String _charset; |
129 private boolean _expect = false; | |
130 private boolean _expect100Continue = false; | |
131 private boolean _expect102Processing = false; | |
132 private boolean _head = false; | |
133 private boolean _host = false; | |
134 private boolean _delayedHandling=false; | |
135 private boolean _earlyEOF = false; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
136 |
826 | 137 /* ------------------------------------------------------------ */ |
138 public static AbstractHttpConnection getCurrentConnection() | |
139 { | |
140 return __currentConnection.get(); | |
141 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
142 |
826 | 143 /* ------------------------------------------------------------ */ |
144 protected static void setCurrentConnection(AbstractHttpConnection connection) | |
145 { | |
146 __currentConnection.set(connection); | |
147 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
148 |
826 | 149 /* ------------------------------------------------------------ */ |
150 public AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server) | |
151 { | |
152 super(endpoint); | |
153 _uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET); | |
154 _connector = connector; | |
155 HttpBuffers ab = (HttpBuffers)_connector; | |
156 _parser = newHttpParser(ab.getRequestBuffers(), endpoint, new RequestHandler()); | |
157 _requestFields = new HttpFields(); | |
158 _responseFields = new HttpFields(); | |
159 _request = new Request(this); | |
160 _response = new Response(this); | |
161 _generator = newHttpGenerator(ab.getResponseBuffers(), endpoint); | |
162 _server = server; | |
163 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
164 |
826 | 165 /* ------------------------------------------------------------ */ |
166 protected AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server, | |
167 Parser parser, Generator generator, Request request) | |
168 { | |
169 super(endpoint); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
170 |
826 | 171 _uri = URIUtil.__CHARSET.equals(StringUtil.__UTF8)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET); |
172 _connector = connector; | |
173 _parser = parser; | |
174 _requestFields = new HttpFields(); | |
175 _responseFields = new HttpFields(); | |
176 _request = request; | |
177 _response = new Response(this); | |
178 _generator = generator; | |
179 _server = server; | |
180 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
181 |
826 | 182 protected HttpParser newHttpParser(Buffers requestBuffers, EndPoint endpoint, HttpParser.EventHandler requestHandler) |
183 { | |
184 return new HttpParser(requestBuffers, endpoint, requestHandler); | |
185 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
186 |
826 | 187 protected HttpGenerator newHttpGenerator(Buffers responseBuffers, EndPoint endPoint) |
188 { | |
189 return new HttpGenerator(responseBuffers, endPoint); | |
190 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
191 |
826 | 192 /* ------------------------------------------------------------ */ |
193 /** | |
194 * @return the parser used by this connection | |
195 */ | |
196 public Parser getParser() | |
197 { | |
198 return _parser; | |
199 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
200 |
826 | 201 /* ------------------------------------------------------------ */ |
202 /** | |
203 * @return the number of requests handled by this connection | |
204 */ | |
205 public int getRequests() | |
206 { | |
207 return _requests; | |
208 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
209 |
826 | 210 /* ------------------------------------------------------------ */ |
211 public Server getServer() | |
212 { | |
213 return _server; | |
214 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
215 |
826 | 216 /* ------------------------------------------------------------ */ |
217 /** | |
218 * @return Returns the associatedObject. | |
219 */ | |
220 public Object getAssociatedObject() | |
221 { | |
222 return _associatedObject; | |
223 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
224 |
826 | 225 /* ------------------------------------------------------------ */ |
226 /** | |
227 * @param associatedObject The associatedObject to set. | |
228 */ | |
229 public void setAssociatedObject(Object associatedObject) | |
230 { | |
231 _associatedObject = associatedObject; | |
232 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
233 |
826 | 234 /* ------------------------------------------------------------ */ |
235 /** | |
236 * @return Returns the connector. | |
237 */ | |
238 public Connector getConnector() | |
239 { | |
240 return _connector; | |
241 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
242 |
826 | 243 /* ------------------------------------------------------------ */ |
244 /** | |
245 * @return Returns the requestFields. | |
246 */ | |
247 public HttpFields getRequestFields() | |
248 { | |
249 return _requestFields; | |
250 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
251 |
826 | 252 /* ------------------------------------------------------------ */ |
253 /** | |
254 * @return Returns the responseFields. | |
255 */ | |
256 public HttpFields getResponseFields() | |
257 { | |
258 return _responseFields; | |
259 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
260 |
826 | 261 /* ------------------------------------------------------------ */ |
262 /** | |
263 * Find out if the request supports CONFIDENTIAL security. | |
264 * @param request the incoming HTTP request | |
265 * @return the result of calling {@link Connector#isConfidential(Request)}, or false | |
266 * if there is no connector | |
267 */ | |
268 public boolean isConfidential(Request request) | |
269 { | |
270 return _connector != null && _connector.isConfidential(request); | |
271 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
272 |
826 | 273 /* ------------------------------------------------------------ */ |
274 /** | |
275 * Find out if the request supports INTEGRAL security. | |
276 * @param request the incoming HTTP request | |
277 * @return the result of calling {@link Connector#isIntegral(Request)}, or false | |
278 * if there is no connector | |
279 */ | |
280 public boolean isIntegral(Request request) | |
281 { | |
282 return _connector != null && _connector.isIntegral(request); | |
283 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
284 |
826 | 285 /* ------------------------------------------------------------ */ |
286 /** | |
287 * @return <code>false</code> (this method is not yet implemented) | |
288 */ | |
289 public boolean getResolveNames() | |
290 { | |
291 return _connector.getResolveNames(); | |
292 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
293 |
826 | 294 /* ------------------------------------------------------------ */ |
295 /** | |
296 * @return Returns the request. | |
297 */ | |
298 public Request getRequest() | |
299 { | |
300 return _request; | |
301 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
302 |
826 | 303 /* ------------------------------------------------------------ */ |
304 /** | |
305 * @return Returns the response. | |
306 */ | |
307 public Response getResponse() | |
308 { | |
309 return _response; | |
310 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
311 |
826 | 312 /* ------------------------------------------------------------ */ |
313 /** | |
314 * Get the inputStream from the connection. | |
315 * <p> | |
316 * If the associated response has the Expect header set to 100 Continue, | |
317 * then accessing the input stream indicates that the handler/servlet | |
318 * is ready for the request body and thus a 100 Continue response is sent. | |
319 * | |
320 * @return The input stream for this connection. | |
321 * The stream will be created if it does not already exist. | |
322 * @throws IOException if the input stream cannot be retrieved | |
323 */ | |
324 public ServletInputStream getInputStream() throws IOException | |
325 { | |
326 // If the client is expecting 100 CONTINUE, then send it now. | |
327 if (_expect100Continue) | |
328 { | |
329 // is content missing? | |
330 if (((HttpParser)_parser).getHeaderBuffer()==null || ((HttpParser)_parser).getHeaderBuffer().length()<2) | |
331 { | |
332 if (_generator.isCommitted()) | |
333 throw new IllegalStateException("Committed before 100 Continues"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
334 |
826 | 335 ((HttpGenerator)_generator).send1xx(HttpStatus.CONTINUE_100); |
336 } | |
337 _expect100Continue=false; | |
338 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
339 |
826 | 340 if (_in == null) |
341 _in = new HttpInput(AbstractHttpConnection.this); | |
342 return _in; | |
343 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
344 |
826 | 345 /* ------------------------------------------------------------ */ |
346 /** | |
347 * @return The output stream for this connection. The stream will be created if it does not already exist. | |
348 */ | |
349 public ServletOutputStream getOutputStream() | |
350 { | |
351 if (_out == null) | |
352 _out = new Output(); | |
353 return _out; | |
354 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
355 |
826 | 356 /* ------------------------------------------------------------ */ |
357 /** | |
358 * @param encoding the PrintWriter encoding | |
359 * @return A {@link PrintWriter} wrapping the {@link #getOutputStream output stream}. The writer is created if it | |
360 * does not already exist. | |
361 */ | |
362 public PrintWriter getPrintWriter(String encoding) | |
363 { | |
364 getOutputStream(); | |
365 if (_writer==null) | |
366 { | |
367 _writer=new OutputWriter(); | |
882
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
368 _printWriter = new PrintWriter(_writer) |
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
369 { |
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
370 public void close() |
826 | 371 { |
882
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
372 synchronized (lock) |
826 | 373 { |
882
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
374 try |
826 | 375 { |
882
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
376 out.close(); |
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
377 } |
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
378 catch (IOException e) |
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
379 { |
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
380 setError(); |
826 | 381 } |
382 } | |
882
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
383 } |
d850a5e6ff15
remove UncheckedPrintWriter
Franklin Schmidt <fschmidt@gmail.com>
parents:
878
diff
changeset
|
384 }; |
826 | 385 } |
386 _writer.setCharacterEncoding(encoding); | |
387 return _printWriter; | |
388 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
389 |
826 | 390 /* ------------------------------------------------------------ */ |
391 public boolean isResponseCommitted() | |
392 { | |
393 return _generator.isCommitted(); | |
394 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
395 |
826 | 396 /* ------------------------------------------------------------ */ |
397 public boolean isEarlyEOF() | |
398 { | |
399 return _earlyEOF; | |
400 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
401 |
826 | 402 /* ------------------------------------------------------------ */ |
403 public void reset() | |
404 { | |
405 _parser.reset(); | |
406 _parser.returnBuffers(); // TODO maybe only on unhandle | |
407 _requestFields.clear(); | |
408 _request.recycle(); | |
409 _generator.reset(); | |
410 _generator.returnBuffers();// TODO maybe only on unhandle | |
411 _responseFields.clear(); | |
412 _response.recycle(); | |
413 _uri.clear(); | |
414 _writer=null; | |
415 _earlyEOF = false; | |
416 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
417 |
826 | 418 /* ------------------------------------------------------------ */ |
419 protected void handleRequest() throws IOException | |
420 { | |
421 boolean error = false; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
422 |
826 | 423 String threadName=null; |
424 Throwable async_exception=null; | |
425 try | |
426 { | |
427 if (LOG.isDebugEnabled()) | |
428 { | |
429 threadName=Thread.currentThread().getName(); | |
430 Thread.currentThread().setName(threadName+" - "+_uri); | |
431 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
432 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
433 |
826 | 434 // Loop here to handle async request redispatches. |
435 // The loop is controlled by the call to async.unhandle in the | |
436 // finally block below. If call is from a non-blocking connector, | |
437 // then the unhandle will return false only if an async dispatch has | |
438 // already happened when unhandle is called. For a blocking connector, | |
439 // the wait for the asynchronous dispatch or timeout actually happens | |
440 // within the call to unhandle(). | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
441 |
826 | 442 final Server server=_server; |
443 boolean was_continuation=_request._async.isContinuation(); | |
444 boolean handling=_request._async.handling() && server!=null && server.isRunning(); | |
445 while (handling) | |
446 { | |
447 _request.setHandled(false); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
448 |
826 | 449 String info=null; |
450 try | |
451 { | |
452 _uri.getPort(); | |
453 String path = null; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
454 |
826 | 455 try |
456 { | |
457 path = _uri.getDecodedPath(); | |
458 } | |
459 catch (Exception e) | |
460 { | |
461 LOG.warn("Failed UTF-8 decode for request path, trying ISO-8859-1"); | |
462 LOG.trace("",e); | |
463 path = _uri.getDecodedPath(StringUtil.__ISO_8859_1); | |
464 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
465 |
826 | 466 info=URIUtil.canonicalPath(path); |
467 if (info==null && !_request.getMethod().equals(HttpMethods.CONNECT)) | |
468 { | |
469 if (path==null && _uri.getScheme()!=null && _uri.getHost()!=null) | |
470 { | |
471 info="/"; | |
472 _request.setRequestURI(""); | |
473 } | |
474 else | |
475 throw new HttpException(400); | |
476 } | |
477 _request.setPathInfo(info); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
478 |
826 | 479 if (_out!=null) |
480 _out.reopen(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
481 |
826 | 482 if (_request._async.isInitial()) |
483 { | |
484 _request.setDispatcherType(DispatcherType.REQUEST); | |
485 _connector.customize(_endp, _request); | |
486 server.handle(this); | |
487 } | |
488 else | |
489 { | |
490 if (_request._async.isExpired()&&!was_continuation) | |
491 { | |
492 async_exception = (Throwable)_request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); | |
493 _response.setStatus(500,async_exception==null?"Async Timeout":"Async Exception"); | |
494 _request.setAttribute(RequestDispatcher.ERROR_STATUS_CODE,new Integer(500)); | |
495 _request.setAttribute(RequestDispatcher.ERROR_MESSAGE, _response.getReason()); | |
496 _request.setDispatcherType(DispatcherType.ERROR); | |
497 } | |
498 else | |
499 _request.setDispatcherType(DispatcherType.ASYNC); | |
500 server.handleAsync(this); | |
501 } | |
502 } | |
503 catch (ContinuationThrowable e) | |
504 { | |
505 LOG.trace("",e); | |
506 } | |
507 catch (EofException e) | |
508 { | |
509 async_exception=e; | |
510 LOG.debug("",e); | |
511 error=true; | |
512 _request.setHandled(true); | |
513 if (!_response.isCommitted()) | |
514 _generator.sendError(500, null, null, true); | |
515 } | |
516 catch (RuntimeIOException e) | |
517 { | |
518 async_exception=e; | |
519 LOG.debug("",e); | |
520 error=true; | |
521 _request.setHandled(true); | |
522 } | |
523 catch (HttpException e) | |
524 { | |
525 LOG.debug("",e); | |
526 error=true; | |
527 _request.setHandled(true); | |
528 _response.sendError(e.getStatus(), e.getReason()); | |
529 } | |
530 catch (Throwable e) | |
531 { | |
532 async_exception=e; | |
533 LOG.warn(String.valueOf(_uri),e); | |
534 error=true; | |
535 _request.setHandled(true); | |
536 _generator.sendError(info==null?400:500, null, null, true); | |
537 | |
538 } | |
539 finally | |
540 { | |
541 // Complete async requests | |
542 if (error && _request.isAsyncStarted()) | |
543 _request.getAsyncContinuation().errorComplete(); | |
544 | |
545 was_continuation=_request._async.isContinuation(); | |
546 handling = !_request._async.unhandle() && server.isRunning() && _server!=null; | |
547 } | |
548 } | |
549 } | |
550 finally | |
551 { | |
552 if (threadName!=null) | |
553 Thread.currentThread().setName(threadName); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
554 |
826 | 555 if (_request._async.isUncompleted()) |
556 { | |
557 | |
558 _request._async.doComplete(async_exception); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
559 |
826 | 560 if (_expect100Continue) |
561 { | |
562 LOG.debug("100 continues not sent"); | |
563 // We didn't send 100 continues, but the latest interpretation | |
564 // of the spec (see httpbis) is that the client will either | |
565 // send the body anyway, or close. So we no longer need to | |
566 // do anything special here other than make the connection not persistent | |
567 _expect100Continue = false; | |
568 if (!_response.isCommitted()) | |
569 _generator.setPersistent(false); | |
570 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
571 |
826 | 572 if(_endp.isOpen()) |
573 { | |
574 if (error) | |
575 { | |
576 _endp.shutdownOutput(); | |
577 _generator.setPersistent(false); | |
578 if (!_generator.isComplete()) | |
579 _response.complete(); | |
580 } | |
581 else | |
582 { | |
583 if (!_response.isCommitted() && !_request.isHandled()) | |
584 _response.sendError(HttpServletResponse.SC_NOT_FOUND); | |
585 _response.complete(); | |
586 if (_generator.isPersistent()) | |
587 _connector.persist(_endp); | |
588 } | |
589 } | |
590 else | |
591 { | |
592 _response.complete(); | |
593 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
594 |
826 | 595 _request.setHandled(true); |
596 } | |
597 } | |
598 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
599 |
826 | 600 /* ------------------------------------------------------------ */ |
601 public abstract Connection handle() throws IOException; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
602 |
826 | 603 /* ------------------------------------------------------------ */ |
604 public void commitResponse(boolean last) throws IOException | |
605 { | |
606 if (!_generator.isCommitted()) | |
607 { | |
608 _generator.setResponse(_response.getStatus(), _response.getReason()); | |
609 try | |
610 { | |
611 // If the client was expecting 100 continues, but we sent something | |
612 // else, then we need to close the connection | |
613 if (_expect100Continue && _response.getStatus()!=100) | |
614 _generator.setPersistent(false); | |
615 _generator.completeHeader(_responseFields, last); | |
616 } | |
617 catch(RuntimeException e) | |
618 { | |
619 LOG.warn("header full: " + e); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
620 |
826 | 621 _response.reset(); |
622 _generator.reset(); | |
623 _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null); | |
624 _generator.completeHeader(_responseFields,Generator.LAST); | |
625 _generator.complete(); | |
626 throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500); | |
627 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
628 |
826 | 629 } |
630 if (last) | |
631 _generator.complete(); | |
632 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
633 |
826 | 634 /* ------------------------------------------------------------ */ |
635 public void completeResponse() throws IOException | |
636 { | |
637 if (!_generator.isCommitted()) | |
638 { | |
639 _generator.setResponse(_response.getStatus(), _response.getReason()); | |
640 try | |
641 { | |
642 _generator.completeHeader(_responseFields, Generator.LAST); | |
643 } | |
644 catch(RuntimeException e) | |
645 { | |
646 LOG.warn("header full: "+e); | |
647 LOG.debug("",e); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
648 |
826 | 649 _response.reset(); |
650 _generator.reset(); | |
651 _generator.setResponse(HttpStatus.INTERNAL_SERVER_ERROR_500,null); | |
652 _generator.completeHeader(_responseFields,Generator.LAST); | |
653 _generator.complete(); | |
654 throw new HttpException(HttpStatus.INTERNAL_SERVER_ERROR_500); | |
655 } | |
656 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
657 |
826 | 658 _generator.complete(); |
659 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
660 |
826 | 661 /* ------------------------------------------------------------ */ |
662 public void flushResponse() throws IOException | |
663 { | |
664 try | |
665 { | |
666 commitResponse(Generator.MORE); | |
667 _generator.flushBuffer(); | |
668 } | |
669 catch(IOException e) | |
670 { | |
671 throw (e instanceof EofException) ? e:new EofException(e); | |
672 } | |
673 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
674 |
826 | 675 /* ------------------------------------------------------------ */ |
676 public Generator getGenerator() | |
677 { | |
678 return _generator; | |
679 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
680 |
826 | 681 /* ------------------------------------------------------------ */ |
682 public boolean isIncluding() | |
683 { | |
684 return _include>0; | |
685 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
686 |
826 | 687 /* ------------------------------------------------------------ */ |
688 public void include() | |
689 { | |
690 _include++; | |
691 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
692 |
826 | 693 /* ------------------------------------------------------------ */ |
694 public void included() | |
695 { | |
696 _include--; | |
697 if (_out!=null) | |
698 _out.reopen(); | |
699 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
700 |
826 | 701 /* ------------------------------------------------------------ */ |
702 public boolean isIdle() | |
703 { | |
704 return _generator.isIdle() && (_parser.isIdle() || _delayedHandling); | |
705 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
706 |
826 | 707 /* ------------------------------------------------------------ */ |
708 /** | |
709 * @see org.eclipse.jetty.io.Connection#isSuspended() | |
710 */ | |
711 public boolean isSuspended() | |
712 { | |
713 return _request.getAsyncContinuation().isSuspended(); | |
714 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
715 |
826 | 716 /* ------------------------------------------------------------ */ |
717 public void onClose() | |
718 { | |
719 LOG.debug("closed {}",this); | |
720 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
721 |
826 | 722 /* ------------------------------------------------------------ */ |
723 public boolean isExpecting100Continues() | |
724 { | |
725 return _expect100Continue; | |
726 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
727 |
826 | 728 /* ------------------------------------------------------------ */ |
729 public boolean isExpecting102Processing() | |
730 { | |
731 return _expect102Processing; | |
732 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
733 |
826 | 734 /* ------------------------------------------------------------ */ |
735 public int getMaxIdleTime() | |
736 { | |
737 if (_connector.isLowResources() && _endp.getMaxIdleTime()==_connector.getMaxIdleTime()) | |
738 return _connector.getLowResourceMaxIdleTime(); | |
739 if (_endp.getMaxIdleTime()>0) | |
740 return _endp.getMaxIdleTime(); | |
741 return _connector.getMaxIdleTime(); | |
742 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
743 |
826 | 744 /* ------------------------------------------------------------ */ |
745 public String toString() | |
746 { | |
747 return String.format("%s,g=%s,p=%s,r=%d", | |
748 super.toString(), | |
749 _generator, | |
750 _parser, | |
751 _requests); | |
752 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
753 |
826 | 754 /* ------------------------------------------------------------ */ |
755 protected void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException | |
756 { | |
757 uri=uri.asImmutableBuffer(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
758 |
826 | 759 _host = false; |
760 _expect = false; | |
761 _expect100Continue=false; | |
762 _expect102Processing=false; | |
763 _delayedHandling=false; | |
764 _charset=null; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
765 |
826 | 766 if(_request.getTimeStamp()==0) |
767 _request.setTimeStamp(System.currentTimeMillis()); | |
768 _request.setMethod(method.toString()); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
769 |
826 | 770 try |
771 { | |
772 _head=false; | |
773 switch (HttpMethods.CACHE.getOrdinal(method)) | |
774 { | |
775 case HttpMethods.CONNECT_ORDINAL: | |
776 _uri.parseConnect(uri.array(), uri.getIndex(), uri.length()); | |
777 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
778 |
826 | 779 case HttpMethods.HEAD_ORDINAL: |
780 _head=true; | |
781 _uri.parse(uri.array(), uri.getIndex(), uri.length()); | |
782 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
783 |
826 | 784 default: |
785 _uri.parse(uri.array(), uri.getIndex(), uri.length()); | |
786 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
787 |
826 | 788 _request.setUri(_uri); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
789 |
826 | 790 if (version==null) |
791 { | |
792 _request.setProtocol(HttpVersions.HTTP_0_9); | |
793 _version=HttpVersions.HTTP_0_9_ORDINAL; | |
794 } | |
795 else | |
796 { | |
797 version= HttpVersions.CACHE.get(version); | |
798 if (version==null) | |
799 throw new HttpException(HttpStatus.BAD_REQUEST_400,null); | |
800 _version = HttpVersions.CACHE.getOrdinal(version); | |
801 if (_version <= 0) _version = HttpVersions.HTTP_1_0_ORDINAL; | |
802 _request.setProtocol(version.toString()); | |
803 } | |
804 } | |
805 catch (Exception e) | |
806 { | |
807 LOG.debug("",e); | |
808 if (e instanceof HttpException) | |
809 throw (HttpException)e; | |
810 throw new HttpException(HttpStatus.BAD_REQUEST_400,null,e); | |
811 } | |
812 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
813 |
826 | 814 /* ------------------------------------------------------------ */ |
815 protected void parsedHeader(Buffer name, Buffer value) throws IOException | |
816 { | |
817 int ho = HttpHeaders.CACHE.getOrdinal(name); | |
818 switch (ho) | |
819 { | |
820 case HttpHeaders.HOST_ORDINAL: | |
821 // TODO check if host matched a host in the URI. | |
822 _host = true; | |
823 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
824 |
826 | 825 case HttpHeaders.EXPECT_ORDINAL: |
826 if (_version>=HttpVersions.HTTP_1_1_ORDINAL) | |
827 { | |
828 value = HttpHeaderValues.CACHE.lookup(value); | |
829 switch(HttpHeaderValues.CACHE.getOrdinal(value)) | |
830 { | |
831 case HttpHeaderValues.CONTINUE_ORDINAL: | |
832 _expect100Continue=_generator instanceof HttpGenerator; | |
833 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
834 |
826 | 835 case HttpHeaderValues.PROCESSING_ORDINAL: |
836 _expect102Processing=_generator instanceof HttpGenerator; | |
837 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
838 |
826 | 839 default: |
840 String[] values = value.toString().split(","); | |
841 for (int i=0;values!=null && i<values.length;i++) | |
842 { | |
843 CachedBuffer cb=HttpHeaderValues.CACHE.get(values[i].trim()); | |
844 if (cb==null) | |
845 _expect=true; | |
846 else | |
847 { | |
848 switch(cb.getOrdinal()) | |
849 { | |
850 case HttpHeaderValues.CONTINUE_ORDINAL: | |
851 _expect100Continue=_generator instanceof HttpGenerator; | |
852 break; | |
853 case HttpHeaderValues.PROCESSING_ORDINAL: | |
854 _expect102Processing=_generator instanceof HttpGenerator; | |
855 break; | |
856 default: | |
857 _expect=true; | |
858 } | |
859 } | |
860 } | |
861 } | |
862 } | |
863 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
864 |
826 | 865 case HttpHeaders.ACCEPT_ENCODING_ORDINAL: |
866 case HttpHeaders.USER_AGENT_ORDINAL: | |
867 value = HttpHeaderValues.CACHE.lookup(value); | |
868 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
869 |
826 | 870 case HttpHeaders.CONTENT_TYPE_ORDINAL: |
871 value = MimeTypes.CACHE.lookup(value); | |
872 _charset=MimeTypes.getCharsetFromContentType(value); | |
873 break; | |
874 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
875 |
826 | 876 _requestFields.add(name, value); |
877 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
878 |
826 | 879 /* ------------------------------------------------------------ */ |
880 protected void headerComplete() throws IOException | |
881 { | |
882 // Handle idle race | |
883 if (_endp.isOutputShutdown()) | |
884 { | |
885 _endp.close(); | |
886 return; | |
887 } | |
888 | |
889 _requests++; | |
890 _generator.setVersion(_version); | |
891 switch (_version) | |
892 { | |
893 case HttpVersions.HTTP_0_9_ORDINAL: | |
894 break; | |
895 case HttpVersions.HTTP_1_0_ORDINAL: | |
896 _generator.setHead(_head); | |
897 if (_parser.isPersistent()) | |
898 { | |
899 _responseFields.add(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.KEEP_ALIVE_BUFFER); | |
900 _generator.setPersistent(true); | |
901 } | |
902 else if (HttpMethods.CONNECT.equals(_request.getMethod())) | |
903 { | |
904 _generator.setPersistent(true); | |
905 _parser.setPersistent(true); | |
906 } | |
907 break; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
908 |
826 | 909 case HttpVersions.HTTP_1_1_ORDINAL: |
910 _generator.setHead(_head); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
911 |
826 | 912 if (!_parser.isPersistent()) |
913 { | |
914 _responseFields.add(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.CLOSE_BUFFER); | |
915 _generator.setPersistent(false); | |
916 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
917 |
826 | 918 if (!_host) |
919 { | |
920 LOG.debug("!host {}",this); | |
921 _generator.setResponse(HttpStatus.BAD_REQUEST_400, null); | |
922 _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER); | |
923 _generator.completeHeader(_responseFields, true); | |
924 _generator.complete(); | |
925 return; | |
926 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
927 |
826 | 928 if (_expect) |
929 { | |
930 LOG.debug("!expectation {}",this); | |
931 _generator.setResponse(HttpStatus.EXPECTATION_FAILED_417, null); | |
932 _responseFields.put(HttpHeaders.CONNECTION_BUFFER, HttpHeaderValues.CLOSE_BUFFER); | |
933 _generator.completeHeader(_responseFields, true); | |
934 _generator.complete(); | |
935 return; | |
936 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
937 |
826 | 938 break; |
939 default: | |
940 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
941 |
826 | 942 if(_charset!=null) |
943 _request.setCharacterEncodingUnchecked(_charset); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
944 |
826 | 945 // Either handle now or wait for first content |
946 if ((((HttpParser)_parser).getContentLength()<=0 && !((HttpParser)_parser).isChunking())||_expect100Continue) | |
947 handleRequest(); | |
948 else | |
949 _delayedHandling=true; | |
950 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
951 |
826 | 952 /* ------------------------------------------------------------ */ |
953 protected void content(Buffer buffer) throws IOException | |
954 { | |
955 if (_delayedHandling) | |
956 { | |
957 _delayedHandling=false; | |
958 handleRequest(); | |
959 } | |
960 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
961 |
826 | 962 /* ------------------------------------------------------------ */ |
963 public void messageComplete(long contentLength) throws IOException | |
964 { | |
965 if (_delayedHandling) | |
966 { | |
967 _delayedHandling=false; | |
968 handleRequest(); | |
969 } | |
970 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
971 |
826 | 972 /* ------------------------------------------------------------ */ |
973 public void earlyEOF() | |
974 { | |
975 _earlyEOF = true; | |
976 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
977 |
826 | 978 /* ------------------------------------------------------------ */ |
979 /* ------------------------------------------------------------ */ | |
980 /* ------------------------------------------------------------ */ | |
981 private class RequestHandler extends HttpParser.EventHandler | |
982 { | |
983 /* | |
984 * | |
985 * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#startRequest(org.eclipse.io.Buffer, | |
986 * org.eclipse.io.Buffer, org.eclipse.io.Buffer) | |
987 */ | |
988 @Override | |
989 public void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException | |
990 { | |
991 AbstractHttpConnection.this.startRequest(method, uri, version); | |
992 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
993 |
826 | 994 /* |
995 * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#parsedHeaderValue(org.eclipse.io.Buffer) | |
996 */ | |
997 @Override | |
998 public void parsedHeader(Buffer name, Buffer value) throws IOException | |
999 { | |
1000 AbstractHttpConnection.this.parsedHeader(name, value); | |
1001 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1002 |
826 | 1003 /* |
1004 * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#headerComplete() | |
1005 */ | |
1006 @Override | |
1007 public void headerComplete() throws IOException | |
1008 { | |
1009 AbstractHttpConnection.this.headerComplete(); | |
1010 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1011 |
826 | 1012 /* ------------------------------------------------------------ */ |
1013 /* | |
1014 * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#content(int, org.eclipse.io.Buffer) | |
1015 */ | |
1016 @Override | |
1017 public void content(Buffer ref) throws IOException | |
1018 { | |
1019 AbstractHttpConnection.this.content(ref); | |
1020 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1021 |
826 | 1022 /* ------------------------------------------------------------ */ |
1023 /* | |
1024 * (non-Javadoc) | |
1025 * | |
1026 * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#messageComplete(int) | |
1027 */ | |
1028 @Override | |
1029 public void messageComplete(long contentLength) throws IOException | |
1030 { | |
1031 AbstractHttpConnection.this.messageComplete(contentLength); | |
1032 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1033 |
826 | 1034 /* ------------------------------------------------------------ */ |
1035 /* | |
1036 * (non-Javadoc) | |
1037 * | |
1038 * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#startResponse(org.eclipse.io.Buffer, int, | |
1039 * org.eclipse.io.Buffer) | |
1040 */ | |
1041 @Override | |
1042 public void startResponse(Buffer version, int status, Buffer reason) | |
1043 { | |
1044 if (LOG.isDebugEnabled()) | |
1045 LOG.debug("Bad request!: "+version+" "+status+" "+reason); | |
1046 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1047 |
826 | 1048 /* ------------------------------------------------------------ */ |
1049 /* | |
1050 * (non-Javadoc) | |
1051 * | |
1052 * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#earlyEOF() | |
1053 */ | |
1054 @Override | |
1055 public void earlyEOF() | |
1056 { | |
1057 AbstractHttpConnection.this.earlyEOF(); | |
1058 } | |
1059 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1060 |
826 | 1061 /* ------------------------------------------------------------ */ |
1062 /* ------------------------------------------------------------ */ | |
1063 /* ------------------------------------------------------------ */ | |
1064 public class Output extends HttpOutput | |
1065 { | |
1066 Output() | |
1067 { | |
1068 super(AbstractHttpConnection.this); | |
1069 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1070 |
826 | 1071 /* ------------------------------------------------------------ */ |
1072 /* | |
1073 * @see java.io.OutputStream#close() | |
1074 */ | |
1075 @Override | |
1076 public void close() throws IOException | |
1077 { | |
1078 if (isClosed()) | |
1079 return; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1080 |
826 | 1081 if (!isIncluding() && !super._generator.isCommitted()) |
1082 commitResponse(Generator.LAST); | |
1083 else | |
1084 flushResponse(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1085 |
826 | 1086 super.close(); |
1087 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1088 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1089 |
826 | 1090 /* ------------------------------------------------------------ */ |
1091 /* | |
1092 * @see java.io.OutputStream#flush() | |
1093 */ | |
1094 @Override | |
1095 public void flush() throws IOException | |
1096 { | |
1097 if (!super._generator.isCommitted()) | |
1098 commitResponse(Generator.MORE); | |
1099 super.flush(); | |
1100 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1101 |
826 | 1102 /* ------------------------------------------------------------ */ |
1103 /* | |
1104 * @see javax.servlet.ServletOutputStream#print(java.lang.String) | |
1105 */ | |
1106 @Override | |
1107 public void print(String s) throws IOException | |
1108 { | |
1109 if (isClosed()) | |
1110 throw new IOException("Closed"); | |
1111 PrintWriter writer=getPrintWriter(null); | |
1112 writer.print(s); | |
1113 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1114 |
826 | 1115 /* ------------------------------------------------------------ */ |
1116 public void sendResponse(Buffer response) throws IOException | |
1117 { | |
1118 ((HttpGenerator)super._generator).sendResponse(response); | |
1119 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1120 |
826 | 1121 /* ------------------------------------------------------------ */ |
1122 public void sendContent(Object content) throws IOException | |
1123 { | |
1124 Resource resource=null; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1125 |
826 | 1126 if (isClosed()) |
1127 throw new IOException("Closed"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1128 |
826 | 1129 if (super._generator.isWritten()) |
1130 throw new IllegalStateException("!empty"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1131 |
826 | 1132 if (content instanceof Resource) |
1133 { | |
1134 resource=(Resource)content; | |
1135 _responseFields.putDateField(HttpHeaders.LAST_MODIFIED_BUFFER, resource.lastModified()); | |
1136 content=resource.getInputStream(); | |
1137 } | |
1138 | |
1139 // Process content. | |
1140 if (content instanceof Buffer) | |
1141 { | |
1142 super._generator.addContent((Buffer) content, Generator.LAST); | |
1143 commitResponse(Generator.LAST); | |
1144 } | |
1145 else if (content instanceof InputStream) | |
1146 { | |
1147 InputStream in = (InputStream)content; | |
1148 | |
1149 try | |
1150 { | |
1151 int max = super._generator.prepareUncheckedAddContent(); | |
1152 Buffer buffer = super._generator.getUncheckedBuffer(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1153 |
826 | 1154 int len=buffer.readFrom(in,max); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1155 |
826 | 1156 while (len>=0) |
1157 { | |
1158 super._generator.completeUncheckedAddContent(); | |
1159 _out.flush(); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1160 |
826 | 1161 max = super._generator.prepareUncheckedAddContent(); |
1162 buffer = super._generator.getUncheckedBuffer(); | |
1163 len=buffer.readFrom(in,max); | |
1164 } | |
1165 super._generator.completeUncheckedAddContent(); | |
1166 _out.flush(); | |
1167 } | |
1168 finally | |
1169 { | |
1170 if (resource!=null) | |
1171 resource.release(); | |
1172 else | |
1173 in.close(); | |
1174 } | |
1175 } | |
1176 else | |
1177 throw new IllegalArgumentException("unknown content type?"); | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1178 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1179 |
826 | 1180 } |
1181 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1182 |
826 | 1183 /* ------------------------------------------------------------ */ |
1184 /* ------------------------------------------------------------ */ | |
1185 /* ------------------------------------------------------------ */ | |
1186 public class OutputWriter extends HttpWriter | |
1187 { | |
1188 OutputWriter() | |
1189 { | |
1190 super(AbstractHttpConnection.this._out); | |
1191 } | |
1192 } | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1193 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1194 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1195 } |