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