Mercurial Hosting > luan
changeset 972:5ee36654b383
simplify AbstractHttpConnection
line wrap: on
line diff
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/io/Connection.java --- a/src/org/eclipse/jetty/io/Connection.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/io/Connection.java Sat Oct 15 22:42:05 2016 -0600 @@ -34,37 +34,28 @@ */ public interface Connection { - /* ------------------------------------------------------------ */ - /** - * Handle the connection. - * @throws IOException if the handling of I/O operations fail - */ - void handle() throws IOException; + /* ------------------------------------------------------------ */ + /** + * Handle the connection. + * @throws IOException if the handling of I/O operations fail + */ + void handle() throws IOException; - /** - * @return the timestamp at which the connection was created - */ - long getTimeStamp(); + /** + * @return the timestamp at which the connection was created + */ + long getTimeStamp(); - /** - * @return whether this connection is idle, that is not parsing and not generating - * @see #onIdleExpired(long) - */ - boolean isIdle(); + /** + * @return whether this connection is idle, that is not parsing and not generating + * @see #onIdleExpired(long) + */ + boolean isIdle(); - /** - * <p>The semantic of this method is to return true to indicate interest in further reads, - * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p> - * - * @return true to indicate interest in further reads, false otherwise - */ - // TODO: rename to isReadInterested() in the next release - boolean isSuspended(); - - /** - * Called when the connection idle timeout expires - * @param idleForMs how long the connection has been idle - * @see #isIdle() - */ - void onIdleExpired(long idleForMs); + /** + * Called when the connection idle timeout expires + * @param idleForMs how long the connection has been idle + * @see #isIdle() + */ + void onIdleExpired(long idleForMs); }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/io/nio/AsyncConnection.java --- a/src/org/eclipse/jetty/io/nio/AsyncConnection.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/AsyncConnection.java Sat Oct 15 22:42:05 2016 -0600 @@ -24,5 +24,14 @@ public interface AsyncConnection extends Connection { - void onInputShutdown() throws IOException; + void onInputShutdown() throws IOException; + + /** + * <p>The semantic of this method is to return true to indicate interest in further reads, + * or false otherwise, but it is misnamed and should be really called <code>isReadInterested()</code>.</p> + * + * @return true to indicate interest in further reads, false otherwise + */ + // TODO: rename to isReadInterested() in the next release + boolean isSuspended(); }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java --- a/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java Sat Oct 15 22:42:05 2016 -0600 @@ -29,7 +29,6 @@ import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Buffer; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EofException; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/io/nio/SelectorManager.java --- a/src/org/eclipse/jetty/io/nio/SelectorManager.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SelectorManager.java Sat Oct 15 22:42:05 2016 -0600 @@ -36,7 +36,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.component.AbstractLifeCycle;
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/io/nio/SslConnection.java --- a/src/org/eclipse/jetty/io/nio/SslConnection.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/io/nio/SslConnection.java Sat Oct 15 22:42:05 2016 -0600 @@ -30,7 +30,6 @@ import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AsyncEndPoint; import org.eclipse.jetty.io.Buffer; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -761,14 +760,9 @@ _aEndp.setMaxIdleTime(timeMs); } - public Connection getConnection() + public void setConnection(AsyncConnection connection) { - return _connection; - } - - public void setConnection(Connection connection) - { - _connection = (AsyncConnection)connection; + _connection = connection; } public String toString()
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/AbstractHttpConnection.java --- a/src/org/eclipse/jetty/server/AbstractHttpConnection.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/AbstractHttpConnection.java Sat Oct 15 22:42:05 2016 -0600 @@ -48,7 +48,6 @@ import org.eclipse.jetty.io.Buffer; import org.eclipse.jetty.io.BufferCache.CachedBuffer; import org.eclipse.jetty.io.Buffers; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.RuntimeIOException; @@ -94,32 +93,27 @@ { private static final Logger LOG = LoggerFactory.getLogger(AbstractHttpConnection.class); - private static final int UNKNOWN = -2; private static final ThreadLocal<AbstractHttpConnection> __currentConnection = new ThreadLocal<AbstractHttpConnection>(); private int _requests; - protected final Connector _connector; - protected final Server _server; - protected final HttpURI _uri; + private final Connector _connector; + private final Server _server; + protected final HttpURI _uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET); - protected final Parser _parser; - protected final HttpFields _requestFields; - protected final Request _request; - protected volatile ServletInputStream _in; + protected final HttpParser _parser; + protected final HttpFields _requestFields = new HttpFields(); + private final Request _request; + private volatile ServletInputStream _in; - protected final Generator _generator; - protected final HttpFields _responseFields; + protected final HttpGenerator _generator; + final HttpFields _responseFields = new HttpFields(); protected final Response _response; - protected volatile Output _out; - protected volatile OutputWriter _writer; - protected volatile PrintWriter _printWriter; + private volatile Output _out; + private volatile HttpWriter _writer; + private volatile PrintWriter _printWriter; - int _include; - - private Object _associatedObject; // associated object - - private int _version = UNKNOWN; + private int _version = -2; // UNKNOWN private String _charset; private boolean _expect = false; @@ -127,159 +121,42 @@ private boolean _expect102Processing = false; private boolean _head = false; private boolean _host = false; - private boolean _delayedHandling=false; + private boolean _delayedHandling = false; private boolean _earlyEOF = false; - /* ------------------------------------------------------------ */ public static AbstractHttpConnection getCurrentConnection() { return __currentConnection.get(); } - /* ------------------------------------------------------------ */ protected static void setCurrentConnection(AbstractHttpConnection connection) { __currentConnection.set(connection); } - /* ------------------------------------------------------------ */ - public AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server) - { - super(endpoint); - _uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET); - _connector = connector; - HttpBuffers ab = (HttpBuffers)_connector; - _parser = newHttpParser(ab.getRequestBuffers(), endpoint, new RequestHandler()); - _requestFields = new HttpFields(); - _responseFields = new HttpFields(); - _request = new Request(this); - _response = new Response(this); - _generator = newHttpGenerator(ab.getResponseBuffers(), endpoint); - _server = server; - } - - /* ------------------------------------------------------------ */ - protected AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server, - Parser parser, Generator generator, Request request) + protected AbstractHttpConnection(Connector connector, EndPoint endpoint) { super(endpoint); - - _uri = URIUtil.__CHARSET.equals(StringUtil.__UTF8)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET); _connector = connector; - _parser = parser; - _requestFields = new HttpFields(); - _responseFields = new HttpFields(); - _request = request; + HttpBuffers ab = _connector; + _parser = new HttpParser(ab.getRequestBuffers(), endpoint, new RequestHandler()); + _request = new Request(this); _response = new Response(this); - _generator = generator; - _server = server; - } - - protected HttpParser newHttpParser(Buffers requestBuffers, EndPoint endpoint, HttpParser.EventHandler requestHandler) - { - return new HttpParser(requestBuffers, endpoint, requestHandler); - } - - protected HttpGenerator newHttpGenerator(Buffers responseBuffers, EndPoint endPoint) - { - return new HttpGenerator(responseBuffers, endPoint); + _generator = new HttpGenerator(ab.getResponseBuffers(), endpoint); + _server = connector.server; } - /* ------------------------------------------------------------ */ - /** - * @return the parser used by this connection - */ - public Parser getParser() - { - return _parser; - } - - /* ------------------------------------------------------------ */ - /** - * @return the number of requests handled by this connection - */ - public int getRequests() - { - return _requests; - } - - /* ------------------------------------------------------------ */ - public Server getServer() - { - return _server; - } - - /* ------------------------------------------------------------ */ - /** - * @return Returns the associatedObject. - */ - public Object getAssociatedObject() - { - return _associatedObject; - } - - /* ------------------------------------------------------------ */ - /** - * @param associatedObject The associatedObject to set. - */ - public void setAssociatedObject(Object associatedObject) - { - _associatedObject = associatedObject; - } - - /* ------------------------------------------------------------ */ - /** - * @return Returns the connector. - */ - public Connector getConnector() + public final Connector getConnector() { return _connector; } - /* ------------------------------------------------------------ */ - /** - * @return Returns the requestFields. - */ - public HttpFields getRequestFields() - { - return _requestFields; - } - - /* ------------------------------------------------------------ */ - /** - * @return Returns the responseFields. - */ - public HttpFields getResponseFields() - { - return _responseFields; - } - - /* ------------------------------------------------------------ */ - /** - * Find out if the request supports CONFIDENTIAL security. - * @param request the incoming HTTP request - * @return the result of calling {@link Connector#isConfidential(Request)}, or false - * if there is no connector - */ - public boolean isConfidential(Request request) - { - return _connector != null && _connector.isConfidential(request); - } - - /* ------------------------------------------------------------ */ - /** - * @return Returns the request. - */ - public Request getRequest() + public final Request getRequest() { return _request; } - /* ------------------------------------------------------------ */ - /** - * @return Returns the response. - */ - public Response getResponse() + public final Response getResponse() { return _response; } @@ -296,18 +173,18 @@ * The stream will be created if it does not already exist. * @throws IOException if the input stream cannot be retrieved */ - public ServletInputStream getInputStream() throws IOException + public final ServletInputStream getInputStream() throws IOException { // If the client is expecting 100 CONTINUE, then send it now. if (_expect100Continue) { // is content missing? - if (((HttpParser)_parser).getHeaderBuffer()==null || ((HttpParser)_parser).getHeaderBuffer().length()<2) + if (_parser.getHeaderBuffer()==null || _parser.getHeaderBuffer().length()<2) { if (_generator.isCommitted()) throw new IllegalStateException("Committed before 100 Continues"); - ((HttpGenerator)_generator).send1xx(HttpStatus.CONTINUE_100); + _generator.send1xx(HttpStatus.CONTINUE_100); } _expect100Continue=false; } @@ -321,7 +198,7 @@ /** * @return The output stream for this connection. The stream will be created if it does not already exist. */ - public ServletOutputStream getOutputStream() + public final ServletOutputStream getOutputStream() { if (_out == null) _out = new Output(); @@ -334,12 +211,12 @@ * @return A {@link PrintWriter} wrapping the {@link #getOutputStream output stream}. The writer is created if it * does not already exist. */ - public PrintWriter getPrintWriter(String encoding) + public final PrintWriter getPrintWriter(String encoding) { getOutputStream(); if (_writer==null) { - _writer=new OutputWriter(); + _writer = new HttpWriter(_out); _printWriter = new PrintWriter(_writer) { public void close() @@ -362,20 +239,12 @@ return _printWriter; } - /* ------------------------------------------------------------ */ - public boolean isResponseCommitted() - { - return _generator.isCommitted(); - } - - /* ------------------------------------------------------------ */ - public boolean isEarlyEOF() + public final boolean isEarlyEOF() { return _earlyEOF; } - /* ------------------------------------------------------------ */ - public void reset() + protected void reset() { _parser.reset(); _parser.returnBuffers(); // TODO maybe only on unhandle @@ -386,11 +255,11 @@ _responseFields.clear(); _response.recycle(); _uri.clear(); - _writer=null; + _writer = null; _earlyEOF = false; } - protected void handleRequest() throws IOException + private void handleRequest() throws IOException { boolean error = false; @@ -513,7 +382,7 @@ } - public void commitResponse(boolean last) throws IOException + public final void commitResponse(boolean last) throws IOException { if (!_generator.isCommitted()) { @@ -543,8 +412,7 @@ _generator.complete(); } - /* ------------------------------------------------------------ */ - public void completeResponse() throws IOException + public final void completeResponse() throws IOException { if (!_generator.isCommitted()) { @@ -570,8 +438,7 @@ _generator.complete(); } - /* ------------------------------------------------------------ */ - public void flushResponse() throws IOException + public final void flushResponse() throws IOException { try { @@ -584,57 +451,17 @@ } } - /* ------------------------------------------------------------ */ - public Generator getGenerator() - { - return _generator; - } - - /* ------------------------------------------------------------ */ - public boolean isIncluding() - { - return _include>0; - } - - /* ------------------------------------------------------------ */ - public void include() - { - _include++; - } - - /* ------------------------------------------------------------ */ - public void included() - { - _include--; - if (_out!=null) - _out.reopen(); - } - - public boolean isIdle() + public final boolean isIdle() { return _generator.isIdle() && (_parser.isIdle() || _delayedHandling); } - /* ------------------------------------------------------------ */ - /** - * @see org.eclipse.jetty.io.Connection#isSuspended() - */ - public boolean isSuspended() - { - return false; - } - - public boolean isExpecting100Continues() - { - return _expect100Continue; - } - - public boolean isExpecting102Processing() + public final boolean isExpecting102Processing() { return _expect102Processing; } - public int getMaxIdleTime() + public final int getMaxIdleTime() { if (_connector.isLowResources() && _endp.getMaxIdleTime()==_connector.getMaxIdleTime()) return 0; @@ -643,6 +470,7 @@ return _connector.getMaxIdleTime(); } + @Override public String toString() { return String.format("%s,g=%s,p=%s,r=%d", @@ -652,14 +480,13 @@ _requests); } - /* ------------------------------------------------------------ */ - protected void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException + private void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException { uri=uri.asImmutableBuffer(); _host = false; _expect = false; - _expect100Continue=false; + _expect100Continue = false; _expect102Processing=false; _delayedHandling=false; _charset=null; @@ -670,7 +497,7 @@ try { - _head=false; + _head = false; switch (HttpMethods.CACHE.getOrdinal(method)) { case HttpMethods.CONNECT_ORDINAL: @@ -678,7 +505,7 @@ break; case HttpMethods.HEAD_ORDINAL: - _head=true; + _head = true; _uri.parse(uri.array(), uri.getIndex(), uri.length()); break; @@ -691,11 +518,11 @@ if (version==null) { _request.setProtocol(HttpVersions.HTTP_0_9); - _version=HttpVersions.HTTP_0_9_ORDINAL; + _version = HttpVersions.HTTP_0_9_ORDINAL; } else { - version= HttpVersions.CACHE.get(version); + version = HttpVersions.CACHE.get(version); if (version==null) throw new HttpException(HttpStatus.BAD_REQUEST_400,null); _version = HttpVersions.CACHE.getOrdinal(version); @@ -712,8 +539,7 @@ } } - /* ------------------------------------------------------------ */ - protected void parsedHeader(Buffer name, Buffer value) throws IOException + private void parsedHeader(Buffer name, Buffer value) throws IOException { int ho = HttpHeaders.CACHE.getOrdinal(name); switch (ho) @@ -730,11 +556,11 @@ switch(HttpHeaderValues.CACHE.getOrdinal(value)) { case HttpHeaderValues.CONTINUE_ORDINAL: - _expect100Continue=_generator instanceof HttpGenerator; + _expect100Continue = true; break; case HttpHeaderValues.PROCESSING_ORDINAL: - _expect102Processing=_generator instanceof HttpGenerator; + _expect102Processing = true; break; default: @@ -743,19 +569,19 @@ { CachedBuffer cb=HttpHeaderValues.CACHE.get(values[i].trim()); if (cb==null) - _expect=true; + _expect = true; else { switch(cb.getOrdinal()) { case HttpHeaderValues.CONTINUE_ORDINAL: - _expect100Continue=_generator instanceof HttpGenerator; + _expect100Continue = true; break; case HttpHeaderValues.PROCESSING_ORDINAL: - _expect102Processing=_generator instanceof HttpGenerator; + _expect102Processing = true; break; default: - _expect=true; + _expect = true; } } } @@ -777,8 +603,7 @@ _requestFields.add(name, value); } - /* ------------------------------------------------------------ */ - protected void headerComplete() throws IOException + private void headerComplete() throws IOException { // Handle idle race if (_endp.isOutputShutdown()) @@ -844,14 +669,13 @@ _request.setCharacterEncodingUnchecked(_charset); // Either handle now or wait for first content - if ((((HttpParser)_parser).getContentLength()<=0 && !((HttpParser)_parser).isChunking())||_expect100Continue) + if ((_parser.getContentLength()<=0 && !_parser.isChunking())||_expect100Continue) handleRequest(); else - _delayedHandling=true; + _delayedHandling = true; } - /* ------------------------------------------------------------ */ - protected void content(Buffer buffer) throws IOException + private void content(Buffer buffer) throws IOException { if (_delayedHandling) { @@ -860,8 +684,7 @@ } } - /* ------------------------------------------------------------ */ - public void messageComplete(long contentLength) throws IOException + private void messageComplete(long contentLength) throws IOException { if (_delayedHandling) { @@ -870,75 +693,44 @@ } } - /* ------------------------------------------------------------ */ - public void earlyEOF() + private void earlyEOF() { _earlyEOF = true; } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ + private class RequestHandler extends HttpParser.EventHandler { - /* - * - * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#startRequest(org.eclipse.io.Buffer, - * org.eclipse.io.Buffer, org.eclipse.io.Buffer) - */ @Override public void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException { AbstractHttpConnection.this.startRequest(method, uri, version); } - /* - * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#parsedHeaderValue(org.eclipse.io.Buffer) - */ @Override public void parsedHeader(Buffer name, Buffer value) throws IOException { AbstractHttpConnection.this.parsedHeader(name, value); } - /* - * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#headerComplete() - */ @Override public void headerComplete() throws IOException { AbstractHttpConnection.this.headerComplete(); } - /* ------------------------------------------------------------ */ - /* - * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#content(int, org.eclipse.io.Buffer) - */ @Override public void content(Buffer ref) throws IOException { AbstractHttpConnection.this.content(ref); } - /* ------------------------------------------------------------ */ - /* - * (non-Javadoc) - * - * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#messageComplete(int) - */ @Override public void messageComplete(long contentLength) throws IOException { AbstractHttpConnection.this.messageComplete(contentLength); } - /* ------------------------------------------------------------ */ - /* - * (non-Javadoc) - * - * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#startResponse(org.eclipse.io.Buffer, int, - * org.eclipse.io.Buffer) - */ @Override public void startResponse(Buffer version, int status, Buffer reason) { @@ -946,12 +738,6 @@ LOG.debug("Bad request!: "+version+" "+status+" "+reason); } - /* ------------------------------------------------------------ */ - /* - * (non-Javadoc) - * - * @see org.eclipse.jetty.server.server.HttpParser.EventHandler#earlyEOF() - */ @Override public void earlyEOF() { @@ -959,10 +745,8 @@ } } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - public class Output extends HttpOutput + + public final class Output extends HttpOutput { Output() { @@ -979,7 +763,7 @@ if (isClosed()) return; - if (!isIncluding() && !super._generator.isCommitted()) + if (!super._generator.isCommitted()) commitResponse(Generator.LAST); else flushResponse(); @@ -1081,16 +865,4 @@ } } - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - /* ------------------------------------------------------------ */ - public class OutputWriter extends HttpWriter - { - OutputWriter() - { - super(AbstractHttpConnection.this._out); - } - } - - }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/AsyncHttpConnection.java --- a/src/org/eclipse/jetty/server/AsyncHttpConnection.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/AsyncHttpConnection.java Sat Oct 15 22:42:05 2016 -0600 @@ -23,10 +23,10 @@ import org.eclipse.jetty.http.HttpException; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.nio.AsyncConnection; import org.eclipse.jetty.io.nio.SelectChannelEndPoint; +import org.eclipse.jetty.server.nio.SelectChannelConnector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ /** Asychronous Server HTTP connection * */ -public class AsyncHttpConnection extends AbstractHttpConnection implements AsyncConnection +public final class AsyncHttpConnection extends AbstractHttpConnection implements AsyncConnection { private final static int NO_PROGRESS_INFO = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_INFO",100); private final static int NO_PROGRESS_CLOSE = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_CLOSE",200); @@ -45,10 +45,10 @@ private final AsyncEndPoint _asyncEndp; private boolean _readInterested = true; - public AsyncHttpConnection(Connector connector, EndPoint endpoint, Server server) + public AsyncHttpConnection(SelectChannelConnector connector, AsyncEndPoint endpoint) { - super(connector,endpoint,server); - _asyncEndp=(AsyncEndPoint)endpoint; + super(connector,endpoint); + _asyncEndp = endpoint; } @Override @@ -155,6 +155,7 @@ } } + @Override public void onInputShutdown() throws IOException { // If we don't have a committed response and we are not suspended @@ -170,7 +171,7 @@ } @Override - public void reset() + protected void reset() { _readInterested = true; LOG.debug("Enabled read interest {}", _endp); @@ -180,6 +181,6 @@ @Override public boolean isSuspended() { - return !_readInterested || super.isSuspended(); + return !_readInterested; } }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/BlockingHttpConnection.java --- a/src/org/eclipse/jetty/server/BlockingHttpConnection.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/BlockingHttpConnection.java Sat Oct 15 22:42:05 2016 -0600 @@ -24,8 +24,8 @@ import org.eclipse.jetty.http.HttpException; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.Parser; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; +import org.eclipse.jetty.server.nio.BlockingChannelConnector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,24 +33,13 @@ /* ------------------------------------------------------------ */ /** Blocking Server HTTP Connection */ -public class BlockingHttpConnection extends AbstractHttpConnection +public final class BlockingHttpConnection extends AbstractHttpConnection { private static final Logger LOG = LoggerFactory.getLogger(BlockingHttpConnection.class); - public BlockingHttpConnection(Connector connector, EndPoint endpoint, Server server) - { - super(connector,endpoint,server); - } - - public BlockingHttpConnection(Connector connector, EndPoint endpoint, Server server, Parser parser, Generator generator, Request request) + public BlockingHttpConnection(BlockingChannelConnector connector, EndPoint endpoint) { - super(connector,endpoint,server,parser,generator,request); - } - - @Override - protected void handleRequest() throws IOException - { - super.handleRequest(); + super(connector,endpoint); } @Override
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/Connector.java --- a/src/org/eclipse/jetty/server/Connector.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/Connector.java Sat Oct 15 22:42:05 2016 -0600 @@ -35,7 +35,6 @@ import org.eclipse.jetty.http.HttpSchemes; import org.eclipse.jetty.io.Buffers; import org.eclipse.jetty.io.Buffers.Type; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.util.component.AggregateLifeCycle; @@ -189,7 +188,7 @@ { } - public boolean isConfidential(Request request) + public boolean isConfidential() { return false; }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/HttpInput.java --- a/src/org/eclipse/jetty/server/HttpInput.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/HttpInput.java Sat Oct 15 22:42:05 2016 -0600 @@ -28,48 +28,47 @@ public class HttpInput extends ServletInputStream { - protected final AbstractHttpConnection _connection; - protected final HttpParser _parser; + protected final AbstractHttpConnection _connection; + protected final HttpParser _parser; - /* ------------------------------------------------------------ */ - public HttpInput(AbstractHttpConnection connection) - { - _connection=connection; - _parser=(HttpParser)connection.getParser(); - } - - /* ------------------------------------------------------------ */ - /* - * @see java.io.InputStream#read() - */ - @Override - public int read() throws IOException - { - byte[] bytes = new byte[1]; - int read = read(bytes, 0, 1); - return read < 0 ? -1 : 0xff & bytes[0]; - } - - /* ------------------------------------------------------------ */ - /* - * @see java.io.InputStream#read(byte[], int, int) - */ - @Override - public int read(byte[] b, int off, int len) throws IOException - { - int l=-1; - Buffer content=_parser.blockForContent(_connection.getMaxIdleTime()); - if (content!=null) - l= content.get(b, off, len); - else if (_connection.isEarlyEOF()) - throw new EofException("early EOF"); - return l; - } + public HttpInput(AbstractHttpConnection connection) + { + _connection = connection; + _parser = connection._parser; + } + + /* ------------------------------------------------------------ */ + /* + * @see java.io.InputStream#read() + */ + @Override + public int read() throws IOException + { + byte[] bytes = new byte[1]; + int read = read(bytes, 0, 1); + return read < 0 ? -1 : 0xff & bytes[0]; + } + + /* ------------------------------------------------------------ */ + /* + * @see java.io.InputStream#read(byte[], int, int) + */ + @Override + public int read(byte[] b, int off, int len) throws IOException + { + int l=-1; + Buffer content=_parser.blockForContent(_connection.getMaxIdleTime()); + if (content!=null) + l= content.get(b, off, len); + else if (_connection.isEarlyEOF()) + throw new EofException("early EOF"); + return l; + } - /* ------------------------------------------------------------ */ - @Override - public int available() throws IOException - { - return _parser.available(); - } + /* ------------------------------------------------------------ */ + @Override + public int available() throws IOException + { + return _parser.available(); + } }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/HttpOutput.java --- a/src/org/eclipse/jetty/server/HttpOutput.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/HttpOutput.java Sat Oct 15 22:42:05 2016 -0600 @@ -41,143 +41,143 @@ */ public class HttpOutput extends ServletOutputStream { - protected final AbstractHttpConnection _connection; - protected final AbstractGenerator _generator; - private boolean _closed; - private ByteArrayBuffer _onebyte; - - // These are held here for reuse by Writer - String _characterEncoding; - Writer _converter; - char[] _chars; - ByteArrayOutputStream2 _bytes; + protected final AbstractHttpConnection _connection; + protected final AbstractGenerator _generator; + private boolean _closed; + private ByteArrayBuffer _onebyte; + + // These are held here for reuse by Writer + String _characterEncoding; + Writer _converter; + char[] _chars; + ByteArrayOutputStream2 _bytes; - /* ------------------------------------------------------------ */ - public HttpOutput(AbstractHttpConnection connection) - { - _connection=connection; - _generator=(AbstractGenerator)connection.getGenerator(); - } + /* ------------------------------------------------------------ */ + public HttpOutput(AbstractHttpConnection connection) + { + _connection = connection; + _generator = connection._generator; + } - /* ------------------------------------------------------------ */ - public int getMaxIdleTime() - { - return _connection.getMaxIdleTime(); - } - - /* ------------------------------------------------------------ */ - public boolean isWritten() - { - return _generator.getContentWritten()>0; - } - - /* ------------------------------------------------------------ */ - /* - * @see java.io.OutputStream#close() - */ - @Override - public void close() throws IOException - { - _closed=true; - } - - /* ------------------------------------------------------------ */ - public boolean isClosed() - { - return _closed; - } - - /* ------------------------------------------------------------ */ - public void reopen() - { - _closed=false; - } - - /* ------------------------------------------------------------ */ - @Override - public void flush() throws IOException - { - _generator.flush(getMaxIdleTime()); - } + /* ------------------------------------------------------------ */ + public int getMaxIdleTime() + { + return _connection.getMaxIdleTime(); + } + + /* ------------------------------------------------------------ */ + public boolean isWritten() + { + return _generator.getContentWritten()>0; + } + + /* ------------------------------------------------------------ */ + /* + * @see java.io.OutputStream#close() + */ + @Override + public void close() throws IOException + { + _closed=true; + } + + /* ------------------------------------------------------------ */ + public boolean isClosed() + { + return _closed; + } + + /* ------------------------------------------------------------ */ + public void reopen() + { + _closed=false; + } + + /* ------------------------------------------------------------ */ + @Override + public void flush() throws IOException + { + _generator.flush(getMaxIdleTime()); + } - /* ------------------------------------------------------------ */ - @Override - public void write(byte[] b, int off, int len) throws IOException - { - write(new ByteArrayBuffer(b,off,len)); - } + /* ------------------------------------------------------------ */ + @Override + public void write(byte[] b, int off, int len) throws IOException + { + write(new ByteArrayBuffer(b,off,len)); + } - /* ------------------------------------------------------------ */ - /* - * @see java.io.OutputStream#write(byte[]) - */ - @Override - public void write(byte[] b) throws IOException - { - write(new ByteArrayBuffer(b)); - } + /* ------------------------------------------------------------ */ + /* + * @see java.io.OutputStream#write(byte[]) + */ + @Override + public void write(byte[] b) throws IOException + { + write(new ByteArrayBuffer(b)); + } - - /* ------------------------------------------------------------ */ - /* - * @see java.io.OutputStream#write(int) - */ - @Override - public void write(int b) throws IOException - { - if (_onebyte==null) - _onebyte=new ByteArrayBuffer(1); - else - _onebyte.clear(); - _onebyte.put((byte)b); - write(_onebyte); - } + + /* ------------------------------------------------------------ */ + /* + * @see java.io.OutputStream#write(int) + */ + @Override + public void write(int b) throws IOException + { + if (_onebyte==null) + _onebyte=new ByteArrayBuffer(1); + else + _onebyte.clear(); + _onebyte.put((byte)b); + write(_onebyte); + } - /* ------------------------------------------------------------ */ - private void write(Buffer buffer) throws IOException - { - if (_closed) - throw new IOException("Closed"); - if (!_generator.isOpen()) - throw new EofException(); - - // Block until we can add _content. - while (_generator.isBufferFull()) - { - _generator.blockForOutput(getMaxIdleTime()); - if (_closed) - throw new IOException("Closed"); - if (!_generator.isOpen()) - throw new EofException(); - } + /* ------------------------------------------------------------ */ + private void write(Buffer buffer) throws IOException + { + if (_closed) + throw new IOException("Closed"); + if (!_generator.isOpen()) + throw new EofException(); + + // Block until we can add _content. + while (_generator.isBufferFull()) + { + _generator.blockForOutput(getMaxIdleTime()); + if (_closed) + throw new IOException("Closed"); + if (!_generator.isOpen()) + throw new EofException(); + } - // Add the _content - _generator.addContent(buffer, Generator.MORE); + // Add the _content + _generator.addContent(buffer, Generator.MORE); - // Have to flush and complete headers? - - if (_generator.isAllContentWritten()) - { - flush(); - close(); - } - else if (_generator.isBufferFull()) - _connection.commitResponse(Generator.MORE); + // Have to flush and complete headers? + + if (_generator.isAllContentWritten()) + { + flush(); + close(); + } + else if (_generator.isBufferFull()) + _connection.commitResponse(Generator.MORE); - // Block until our buffer is free - while (buffer.length() > 0 && _generator.isOpen()) - { - _generator.blockForOutput(getMaxIdleTime()); - } - } + // Block until our buffer is free + while (buffer.length() > 0 && _generator.isOpen()) + { + _generator.blockForOutput(getMaxIdleTime()); + } + } - /* ------------------------------------------------------------ */ - /* - * @see javax.servlet.ServletOutputStream#print(java.lang.String) - */ - @Override - public void print(String s) throws IOException - { - write(s.getBytes()); - } + /* ------------------------------------------------------------ */ + /* + * @see javax.servlet.ServletOutputStream#print(java.lang.String) + */ + @Override + public void print(String s) throws IOException + { + write(s.getBytes()); + } }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/Request.java --- a/src/org/eclipse/jetty/server/Request.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/Request.java Sat Oct 15 22:42:05 2016 -0600 @@ -133,7 +133,6 @@ private static final int __NONE = 0, _STREAM = 1, __READER = 2; - /* ------------------------------------------------------------ */ public static Request getRequest(HttpServletRequest request) { if (request instanceof Request) @@ -435,15 +434,15 @@ */ public int getContentLength() { - return (int)_connection.getRequestFields().getLongField(HttpHeaders.CONTENT_LENGTH_BUFFER); + return (int)_connection._requestFields.getLongField(HttpHeaders.CONTENT_LENGTH_BUFFER); } public long getContentRead() { - if (_connection == null || _connection.getParser() == null) + if (_connection == null) return -1; - return ((HttpParser)_connection.getParser()).getContentRead(); + return _connection._parser.getContentRead(); } /* ------------------------------------------------------------ */ @@ -452,7 +451,7 @@ */ public String getContentType() { - return _connection.getRequestFields().getStringField(HttpHeaders.CONTENT_TYPE_BUFFER); + return _connection._requestFields.getStringField(HttpHeaders.CONTENT_TYPE_BUFFER); } /* ------------------------------------------------------------ */ @@ -484,7 +483,7 @@ _cookiesExtracted = true; - Enumeration enm = _connection.getRequestFields().getValues(HttpHeaders.COOKIE_BUFFER); + Enumeration enm = _connection._requestFields.getValues(HttpHeaders.COOKIE_BUFFER); // Handle no cookies if (enm != null) @@ -508,7 +507,7 @@ */ public long getDateHeader(String name) { - return _connection.getRequestFields().getDateField(name); + return _connection._requestFields.getDateField(name); } /* ------------------------------------------------------------ */ @@ -523,7 +522,7 @@ */ public String getHeader(String name) { - return _connection.getRequestFields().getStringField(name); + return _connection._requestFields.getStringField(name); } /* ------------------------------------------------------------ */ @@ -532,7 +531,7 @@ */ public Enumeration getHeaderNames() { - return _connection.getRequestFields().getFieldNames(); + return _connection._requestFields.getFieldNames(); } /* ------------------------------------------------------------ */ @@ -541,7 +540,7 @@ */ public Enumeration getHeaders(String name) { - Enumeration e = _connection.getRequestFields().getValues(name); + Enumeration e = _connection._requestFields.getValues(name); if (e == null) return Collections.enumeration(Collections.EMPTY_LIST); return e; @@ -574,7 +573,7 @@ */ public int getIntHeader(String name) { - return (int)_connection.getRequestFields().getLongField(name); + return (int)_connection._requestFields.getLongField(name); } /* ------------------------------------------------------------ */ @@ -592,7 +591,7 @@ */ public Locale getLocale() { - Enumeration enm = _connection.getRequestFields().getValues( "Accept-Language", ", \t" ); + Enumeration enm = _connection._requestFields.getValues( "Accept-Language", ", \t" ); // handle no locale if (enm == null || !enm.hasMoreElements()) @@ -629,7 +628,7 @@ public Enumeration getLocales() { - Enumeration enm = _connection.getRequestFields().getValues( "Accept-Language", ", \t" ); + Enumeration enm = _connection._requestFields.getValues( "Accept-Language", ", \t" ); // handle no locale if (enm == null || !enm.hasMoreElements()) @@ -1011,7 +1010,7 @@ return _serverName; // Return host from header field - Buffer hostPort = _connection.getRequestFields().get(HttpHeaders.HOST_BUFFER); + Buffer hostPort = _connection._requestFields.get(HttpHeaders.HOST_BUFFER); if (hostPort != null) { loop: for (int i = hostPort.putIndex(); i-- > hostPort.getIndex();) @@ -1255,7 +1254,7 @@ */ public boolean isSecure() { - return _connection.isConfidential(this); + return _connection.getConnector().isConfidential(); } /* ------------------------------------------------------------ */ @@ -1490,7 +1489,7 @@ */ public void setContentType(String contentType) { - _connection.getRequestFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,contentType); + _connection._requestFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,contentType); }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/Response.java --- a/src/org/eclipse/jetty/server/Response.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/Response.java Sat Oct 15 22:42:05 2016 -0600 @@ -82,7 +82,6 @@ public final static String HTTP_ONLY_COMMENT="__HTTP_ONLY__"; - /* ------------------------------------------------------------ */ public static Response getResponse(HttpServletResponse response) { if (response instanceof Response) @@ -137,7 +136,7 @@ */ public void addCookie(HttpCookie cookie) { - _connection.getResponseFields().addSetCookie(cookie); + _connection._responseFields.addSetCookie(cookie); } /* ------------------------------------------------------------ */ @@ -160,7 +159,7 @@ comment=null; } } - _connection.getResponseFields().addSetCookie(cookie.getName(), + _connection._responseFields.addSetCookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(), @@ -177,7 +176,7 @@ */ public boolean containsHeader(String name) { - return _connection.getResponseFields().containsKey(name); + return _connection._responseFields.containsKey(name); } /* ------------------------------------------------------------ */ @@ -218,9 +217,6 @@ */ public void sendError(int code, String message) throws IOException { - if (_connection.isIncluding()) - return; - if (isCommitted()) LOG.warn("Committed before "+code+" "+message); @@ -290,8 +286,8 @@ } else if (code!=SC_PARTIAL_CONTENT) { - _connection.getRequestFields().remove(HttpHeaders.CONTENT_TYPE_BUFFER); - _connection.getRequestFields().remove(HttpHeaders.CONTENT_LENGTH_BUFFER); + _connection._requestFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER); + _connection._requestFields.remove(HttpHeaders.CONTENT_LENGTH_BUFFER); _characterEncoding=null; _mimeType=null; _cachedMimeType=null; @@ -323,7 +319,7 @@ public void sendProcessing() throws IOException { if (_connection.isExpecting102Processing() && !isCommitted()) - ((HttpGenerator)_connection.getGenerator()).send1xx(HttpStatus.PROCESSING_102); + _connection._generator.send1xx(HttpStatus.PROCESSING_102); } /* ------------------------------------------------------------ */ @@ -332,9 +328,6 @@ */ public void sendRedirect(String location) throws IOException { - if (_connection.isIncluding()) - return; - if (location==null) throw new IllegalArgumentException(); @@ -400,8 +393,7 @@ */ public void setDateHeader(String name, long date) { - if (!_connection.isIncluding()) - _connection.getResponseFields().putDateField(name, date); + _connection._responseFields.putDateField(name, date); } /* ------------------------------------------------------------ */ @@ -410,8 +402,7 @@ */ public void addDateHeader(String name, long date) { - if (!_connection.isIncluding()) - _connection.getResponseFields().addDateField(name, date); + _connection._responseFields.addDateField(name, date); } /* ------------------------------------------------------------ */ @@ -424,14 +415,7 @@ setContentType(value); else { - if (_connection.isIncluding()) - { - if (name.startsWith(SET_INCLUDE_HEADER_PREFIX)) - name=name.substring(SET_INCLUDE_HEADER_PREFIX.length()); - else - return; - } - _connection.getResponseFields().put(name, value); + _connection._responseFields.put(name, value); if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) { if (value==null) @@ -446,7 +430,7 @@ /* ------------------------------------------------------------ */ public Collection<String> getHeaderNames() { - final HttpFields fields=_connection.getResponseFields(); + final HttpFields fields=_connection._responseFields; return fields.getFieldNamesCollection(); } @@ -455,7 +439,7 @@ */ public String getHeader(String name) { - return _connection.getResponseFields().getStringField(name); + return _connection._responseFields.getStringField(name); } /* ------------------------------------------------------------ */ @@ -463,7 +447,7 @@ */ public Collection<String> getHeaders(String name) { - final HttpFields fields=_connection.getResponseFields(); + final HttpFields fields=_connection._responseFields; Collection<String> i = fields.getValuesCollection(name); if (i==null) return Collections.EMPTY_LIST; @@ -477,21 +461,13 @@ public void addHeader(String name, String value) { - if (_connection.isIncluding()) - { - if (name.startsWith(SET_INCLUDE_HEADER_PREFIX)) - name=name.substring(SET_INCLUDE_HEADER_PREFIX.length()); - else - return; - } - if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) { setContentType(value); return; } - _connection.getResponseFields().add(name, value); + _connection._responseFields.add(name, value); if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) _connection._generator.setContentLength(Long.parseLong(value)); } @@ -502,12 +478,9 @@ */ public void setIntHeader(String name, int value) { - if (!_connection.isIncluding()) - { - _connection.getResponseFields().putLongField(name, value); - if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) - _connection._generator.setContentLength(value); - } + _connection._responseFields.putLongField(name, value); + if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) + _connection._generator.setContentLength(value); } /* ------------------------------------------------------------ */ @@ -516,12 +489,9 @@ */ public void addIntHeader(String name, int value) { - if (!_connection.isIncluding()) - { - _connection.getResponseFields().addLongField(name, value); - if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) - _connection._generator.setContentLength(value); - } + _connection._responseFields.addLongField(name, value); + if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) + _connection._generator.setContentLength(value); } /* ------------------------------------------------------------ */ @@ -541,11 +511,8 @@ { if (sc<=0) throw new IllegalArgumentException(); - if (!_connection.isIncluding()) - { - _status=sc; - _reason=sm; - } + _status=sc; + _reason=sm; } /* ------------------------------------------------------------ */ @@ -640,9 +607,6 @@ */ public void setCharacterEncoding(String encoding) { - if (_connection.isIncluding()) - return; - if (this._outputState==0 && !isCommitted()) { _explicitEncoding=true; @@ -661,9 +625,9 @@ _contentType=null; if (_contentType==null) - _connection.getResponseFields().remove(HttpHeaders.CONTENT_TYPE_BUFFER); + _connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER); else - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else @@ -682,14 +646,14 @@ if (content_type!=null) { _contentType=content_type.toString(); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); } } if (_contentType==null) { _contentType = _mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else @@ -708,7 +672,7 @@ else _contentType=_contentType.substring(0,i8)+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= ")+_contentType.substring(i2); } - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } } @@ -724,12 +688,12 @@ // Protect from setting after committed as default handling // of a servlet HEAD request ALWAYS sets _content length, even // if the getHandling committed the response! - if (isCommitted() || _connection.isIncluding()) + if (isCommitted()) return; _connection._generator.setContentLength(len); if (len>0) { - _connection.getResponseFields().putLongField(HttpHeaders.CONTENT_LENGTH, len); + _connection._responseFields.putLongField(HttpHeaders.CONTENT_LENGTH, len); if (_connection._generator.isAllContentWritten()) { if (_outputState==WRITER) @@ -758,10 +722,10 @@ // Protect from setting after committed as default handling // of a servlet HEAD request ALWAYS sets _content length, even // if the getHandling committed the response! - if (isCommitted() || _connection.isIncluding()) + if (isCommitted()) return; _connection._generator.setContentLength(len); - _connection.getResponseFields().putLongField(HttpHeaders.CONTENT_LENGTH, len); + _connection._responseFields.putLongField(HttpHeaders.CONTENT_LENGTH, len); } /* ------------------------------------------------------------ */ @@ -770,7 +734,7 @@ */ public void setContentType(String contentType) { - if (isCommitted() || _connection.isIncluding()) + if (isCommitted()) return; // Yes this method is horribly complex.... but there are lots of special cases and @@ -784,7 +748,7 @@ _mimeType=null; _cachedMimeType=null; _contentType=null; - _connection.getResponseFields().remove(HttpHeaders.CONTENT_TYPE_BUFFER); + _connection._responseFields.remove(HttpHeaders.CONTENT_TYPE_BUFFER); } else { @@ -818,29 +782,29 @@ if (content_type!=null) { _contentType=content_type.toString(); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); } else { _contentType=_mimeType+";charset="+_characterEncoding; - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else { _contentType=_mimeType+";charset="+_characterEncoding; - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else if (i2<0) { _contentType=contentType.substring(0,i1)+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } else { _contentType=contentType.substring(0,i1)+contentType.substring(i2)+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else if ((i1==i0+1 && i2<0) || (i1==i0+2 && i2<0 && contentType.charAt(i0+1)==' ')) @@ -855,38 +819,38 @@ if (content_type!=null) { _contentType=content_type.toString(); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); } else { _contentType=contentType; - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else { _contentType=contentType; - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else if (i2>0) { _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8,i2)); _contentType=contentType; - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } else { _characterEncoding = QuotedStringTokenizer.unquote(contentType.substring(i8)); _contentType=contentType; - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else // No encoding in the params. { _cachedMimeType=null; _contentType=_characterEncoding==null?contentType:contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else // No params at all @@ -902,29 +866,29 @@ if (content_type!=null) { _contentType=content_type.toString(); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,content_type); } else { _contentType=_mimeType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else { _contentType=contentType+";charset="+QuotedStringTokenizer.quoteIfNeeded(_characterEncoding,";= "); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } else if (_cachedMimeType!=null) { _contentType=_cachedMimeType.toString(); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_cachedMimeType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_cachedMimeType); } else { _contentType=contentType; - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } } @@ -938,7 +902,7 @@ { if (isCommitted() || getContentCount()>0) throw new IllegalStateException("Committed or content written"); - _connection.getGenerator().increaseContentBufferSize(size); + _connection._generator.increaseContentBufferSize(size); } /* ------------------------------------------------------------ */ @@ -947,7 +911,7 @@ */ public int getBufferSize() { - return _connection.getGenerator().getContentBufferSize(); + return _connection._generator.getContentBufferSize(); } /* ------------------------------------------------------------ */ @@ -970,10 +934,10 @@ _status=200; _reason=null; - HttpFields response_fields=_connection.getResponseFields(); + HttpFields response_fields=_connection._responseFields; response_fields.clear(); - String connection=_connection.getRequestFields().getStringField(HttpHeaders.CONNECTION_BUFFER); + String connection=_connection._requestFields.getStringField(HttpHeaders.CONNECTION_BUFFER); if (connection!=null) { String[] values = connection.split(","); @@ -1009,7 +973,7 @@ reset(); else { - HttpFields response_fields=_connection.getResponseFields(); + HttpFields response_fields=_connection._responseFields; ArrayList<String> cookieValues = new ArrayList<String>(5); Enumeration<String> vals = response_fields.getValues(HttpHeaders.SET_COOKIE); @@ -1045,7 +1009,7 @@ { if (isCommitted()) throw new IllegalStateException("Committed"); - _connection.getGenerator().resetBuffer(); + _connection._generator.resetBuffer(); } /* ------------------------------------------------------------ */ @@ -1054,7 +1018,7 @@ */ public boolean isCommitted() { - return _connection.isResponseCommitted(); + return _connection._generator.isCommitted(); } @@ -1064,11 +1028,11 @@ */ public void setLocale(Locale locale) { - if (locale == null || isCommitted() ||_connection.isIncluding()) + if (locale == null || isCommitted()) return; _locale = locale; - _connection.getResponseFields().put(HttpHeaders.CONTENT_LANGUAGE_BUFFER,locale.toString().replace('_','-')); + _connection._responseFields.put(HttpHeaders.CONTENT_LANGUAGE_BUFFER,locale.toString().replace('_','-')); if (_explicitEncoding || _outputState!=0 ) return; @@ -1100,7 +1064,7 @@ } _cachedMimeType=MimeTypes.CACHE.get(_mimeType); - _connection.getResponseFields().put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); + _connection._responseFields.put(HttpHeaders.CONTENT_TYPE_BUFFER,_contentType); } } } @@ -1151,15 +1115,15 @@ */ public long getContentCount() { - if (_connection==null || _connection.getGenerator()==null) + if (_connection==null) return -1; - return _connection.getGenerator().getContentWritten(); + return _connection._generator.getContentWritten(); } /* ------------------------------------------------------------ */ public HttpFields getHttpFields() { - return _connection.getResponseFields(); + return _connection._responseFields; } /* ------------------------------------------------------------ */ @@ -1167,7 +1131,7 @@ public String toString() { return "HTTP/1.1 "+_status+" "+ (_reason==null?"":_reason) +System.getProperty("line.separator")+ - _connection.getResponseFields().toString(); + _connection._responseFields.toString(); } /* ------------------------------------------------------------ */
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java --- a/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/nio/BlockingChannelConnector.java Sat Oct 15 22:42:05 2016 -0600 @@ -31,7 +31,6 @@ import org.eclipse.jetty.http.HttpException; import org.eclipse.jetty.io.Buffer; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; import org.eclipse.jetty.io.nio.ChannelEndPoint; @@ -140,7 +139,7 @@ private class BlockingChannelEndPoint extends ChannelEndPoint implements Runnable { - private Connection _connection; + private final BlockingHttpConnection _connection; private int _timeout; private volatile long _idleTimestamp; @@ -148,12 +147,7 @@ throws IOException { super(channel,BlockingChannelConnector.this._maxIdleTime); - _connection = new BlockingHttpConnection(BlockingChannelConnector.this,this,server); - } - - public void setConnection(Connection connection) - { - _connection=connection; + _connection = new BlockingHttpConnection(BlockingChannelConnector.this,this); } public void checkIdleTimestamp(long now)
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/nio/SelectChannelConnector.java --- a/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/nio/SelectChannelConnector.java Sat Oct 15 22:42:05 2016 -0600 @@ -26,7 +26,6 @@ import java.nio.channels.SocketChannel; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.nio.AsyncConnection; import org.eclipse.jetty.io.nio.SelectChannelEndPoint; @@ -109,6 +108,6 @@ public AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint) { - return new AsyncHttpConnection(SelectChannelConnector.this,endpoint,server); + return new AsyncHttpConnection(this,endpoint); } }
diff -r f997df37cec1 -r 5ee36654b383 src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java --- a/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Fri Oct 14 13:06:06 2016 -0600 +++ b/src/org/eclipse/jetty/server/ssl/SslSelectChannelConnector.java Sat Oct 15 22:42:05 2016 -0600 @@ -526,7 +526,7 @@ * requiring client certs providing mere INTEGRAL constraints. */ @Override - public boolean isConfidential(Request request) + public boolean isConfidential() { return true; }