diff options
author | Simone Bordet | 2015-08-11 10:17:24 +0000 |
---|---|---|
committer | Simone Bordet | 2015-08-11 10:17:24 +0000 |
commit | aa684a5dccd76d765b1e2376af3f76291c8b1333 (patch) | |
tree | fec77d8773b9b3aca890b9aa0c339b23c606fce8 /jetty-io/src/main/java/org/eclipse/jetty/io | |
parent | 88372913937a5e491dd97679e0e8cba046f0ff1d (diff) | |
download | org.eclipse.jetty.project-aa684a5dccd76d765b1e2376af3f76291c8b1333.tar.gz org.eclipse.jetty.project-aa684a5dccd76d765b1e2376af3f76291c8b1333.tar.xz org.eclipse.jetty.project-aa684a5dccd76d765b1e2376af3f76291c8b1333.zip |
470311 - Introduce a proxy-protocol module.
Support for the PROXY protocol is now enabled via 2 new modules:
proxy-protocol and proxy-protocol-ssl, respectively for the HTTP
connector and the SSL connector.
Diffstat (limited to 'jetty-io/src/main/java/org/eclipse/jetty/io')
3 files changed, 37 insertions, 25 deletions
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java index 52f7b4c83f..f0185b0f0a 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractConnection.java @@ -38,7 +38,7 @@ import org.eclipse.jetty.util.log.Logger; public abstract class AbstractConnection implements Connection { private static final Logger LOG = Log.getLogger(AbstractConnection.class); - + private final List<Listener> listeners = new CopyOnWriteArrayList<>(); private final long _created=System.currentTimeMillis(); private final EndPoint _endPoint; @@ -109,7 +109,7 @@ public abstract class AbstractConnection implements Connection callback.failed(x); } } - + /** * <p>Utility method to be called to register read interest.</p> * <p>After a call to this method, {@link #onFillable()} or {@link #onFillInterestedFailed(Throwable)} @@ -122,12 +122,12 @@ public abstract class AbstractConnection implements Connection LOG.debug("fillInterested {}",this); getEndPoint().fillInterested(_readCallback); } - + public boolean isFillInterested() { - return ((AbstractEndPoint)getEndPoint()).getFillInterest().isInterested(); + return getEndPoint().isFillInterested(); } - + /** * <p>Callback method invoked when the endpoint is ready to be read.</p> * @see #fillInterested() @@ -154,10 +154,10 @@ public abstract class AbstractConnection implements Connection else { _endPoint.shutdownOutput(); - fillInterested(); - } + fillInterested(); + } } - } + } } /** @@ -236,9 +236,9 @@ public abstract class AbstractConnection implements Connection { return String.format("%s@%x", getClass().getSimpleName(), hashCode()); } - + private class ReadCallback implements Callback - { + { @Override public void succeeded() { @@ -250,7 +250,7 @@ public abstract class AbstractConnection implements Connection { onFillInterestedFailed(x); } - + @Override public String toString() { diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java index 8c72303305..73acb763aa 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractEndPoint.java @@ -45,7 +45,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint AbstractEndPoint.this.needsFillInterest(); } }; - + private final WriteFlusher _writeFlusher = new WriteFlusher(this) { @Override @@ -79,7 +79,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint { return _remote; } - + @Override public Connection getConnection() { @@ -115,7 +115,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint _writeFlusher.onClose(); _fillInterest.onClose(); } - + @Override public void close() { @@ -130,6 +130,12 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint } @Override + public boolean isFillInterested() + { + return _fillInterest.isInterested(); + } + + @Override public void write(Callback callback, ByteBuffer... buffers) throws IllegalStateException { _writeFlusher.write(callback, buffers); @@ -156,17 +162,17 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint boolean input_shutdown=isInputShutdown(); boolean fillFailed = _fillInterest.onFail(timeout); boolean writeFailed = _writeFlusher.onFail(timeout); - + // If the endpoint is half closed and there was no fill/write handling, then close here. - // This handles the situation where the connection has completed its close handling + // This handles the situation where the connection has completed its close handling // and the endpoint is half closed, but the other party does not complete the close. // This perhaps should not check for half closed, however the servlet spec case allows - // for a dispatched servlet or suspended request to extend beyond the connections idle - // time. So if this test would always close an idle endpoint that is not handled, then + // for a dispatched servlet or suspended request to extend beyond the connections idle + // time. So if this test would always close an idle endpoint that is not handled, then // we would need a mode to ignore timeouts for some HTTP states if (isOpen() && (output_shutdown || input_shutdown) && !(fillFailed || writeFailed)) close(); - else + else LOG.debug("Ignored idle endpoint {}",this); } @@ -177,7 +183,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint if (LOG.isDebugEnabled()) LOG.debug("{} upgradeing from {} to {}", this, old_connection, newConnection); - + ByteBuffer prefilled = (old_connection instanceof Connection.UpgradeFrom) ?((Connection.UpgradeFrom)old_connection).onUpgradeFrom():null; old_connection.onClose(); @@ -190,7 +196,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint newConnection.onOpen(); } - + @Override public String toString() { @@ -201,7 +207,7 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint c=c.getSuperclass(); name=c.getSimpleName(); } - + return String.format("%s@%x{%s<->%d,%s,%s,%s,%s,%s,%d/%d,%s}", name, hashCode(), diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java index 700193e3e6..cb1cda8083 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/EndPoint.java @@ -32,9 +32,9 @@ import org.eclipse.jetty.util.IteratingCallback; /** * * A transport EndPoint - * + * * <h3>Asynchronous Methods</h3> - * <p>The asynchronous scheduling methods of {@link EndPoint} + * <p>The asynchronous scheduling methods of {@link EndPoint} * has been influenced by NIO.2 Futures and Completion * handlers, but does not use those actual interfaces because they have * some inefficiencies.</p> @@ -170,7 +170,7 @@ public interface EndPoint extends Closeable * are taken from the header/buffer position up until the buffer limit. The header/buffers position * is updated to indicate how many bytes have been consumed. * @param buffer the buffers to flush - * @return True IFF all the buffers have been consumed and the endpoint has flushed the data to its + * @return True IFF all the buffers have been consumed and the endpoint has flushed the data to its * destination (ie is not buffering any data). * @throws IOException If the endpoint is closed or output is shutdown. */ @@ -206,6 +206,12 @@ public interface EndPoint extends Closeable void fillInterested(Callback callback) throws ReadPendingException; /** + * @return whether {@link #fillInterested(Callback)} has been called, but {@link #fill(ByteBuffer)} has not yet + * been called + */ + boolean isFillInterested(); + + /** * <p>Writes the given buffers via {@link #flush(ByteBuffer...)} and invokes callback methods when either * all the data has been flushed or an error occurs.</p> * |