jetty-9 work in progress. Further simplification of jetty-io
This commit is contained in:
parent
e77f4344ac
commit
2bcf611e5e
|
@ -15,11 +15,11 @@ package org.eclipse.jetty.http;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTokens.Content;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.http.HttpTokens.Content;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
|
|
@ -16,12 +16,12 @@ package org.eclipse.jetty.http;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.HttpTokens.Content;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.http.HttpTokens.Content;
|
||||
|
||||
public class HttpParser
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ import static org.junit.Assert.assertNotNull;
|
|||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MimeTypesTest
|
||||
|
|
|
@ -2,39 +2,42 @@ package org.eclipse.jetty.io;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.io.nio.AsyncConnection;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
public abstract class AbstractConnection implements Connection
|
||||
public abstract class AbstractAsyncConnection implements AsyncConnection
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(AbstractConnection.class);
|
||||
private static final Logger LOG = Log.getLogger(AbstractAsyncConnection.class);
|
||||
|
||||
private final long _timeStamp;
|
||||
protected final EndPoint _endp;
|
||||
protected final AsyncEndPoint _endp;
|
||||
|
||||
public AbstractConnection(EndPoint endp)
|
||||
public AbstractAsyncConnection(AsyncEndPoint endp)
|
||||
{
|
||||
_endp=(EndPoint)endp;
|
||||
_endp=endp;
|
||||
_timeStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public AbstractConnection(EndPoint endp,long timestamp)
|
||||
public AbstractAsyncConnection(AsyncEndPoint endp,long timestamp)
|
||||
{
|
||||
_endp=(EndPoint)endp;
|
||||
_endp=endp;
|
||||
_timeStamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AsyncEndPoint getAsyncEndPoint()
|
||||
{
|
||||
return _endp;
|
||||
}
|
||||
|
||||
public long getTimeStamp()
|
||||
{
|
||||
return _timeStamp;
|
||||
}
|
||||
|
||||
public EndPoint getEndPoint()
|
||||
{
|
||||
return _endp;
|
||||
}
|
||||
|
||||
public void onIdleExpired(long idleForMs)
|
||||
{
|
||||
try
|
|
@ -13,10 +13,26 @@
|
|||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.io.nio.AsyncConnection;
|
||||
import org.eclipse.jetty.util.thread.Timeout;
|
||||
|
||||
public interface AsyncEndPoint extends ConnectedEndPoint
|
||||
public interface AsyncEndPoint extends EndPoint
|
||||
{
|
||||
/* ------------------------------------------------------------ */
|
||||
AsyncConnection getAsyncConnection();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
void setAsyncConnection(AsyncConnection connection);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean blockReadable(long millisecs) throws IOException;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean blockWritable(long millisecs) throws IOException;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Dispatch the endpoint to a thread to attend to it.
|
||||
|
@ -49,16 +65,9 @@ public interface AsyncEndPoint extends ConnectedEndPoint
|
|||
*/
|
||||
public boolean isCheckForIdle();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isWritable();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if IO has been successfully performed since the last call to {@link #hasProgressed()}
|
||||
*/
|
||||
public boolean hasProgressed();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
*/
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.GatheringByteChannel;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
|
@ -26,14 +26,13 @@ import org.eclipse.jetty.util.BufferUtil;
|
|||
*
|
||||
*
|
||||
*/
|
||||
public class ByteArrayEndPoint implements ConnectedEndPoint
|
||||
public class ByteArrayEndPoint implements EndPoint
|
||||
{
|
||||
protected byte[] _inBytes;
|
||||
protected ByteBuffer _in;
|
||||
protected ByteBuffer _out;
|
||||
protected boolean _closed;
|
||||
protected boolean _growOutput;
|
||||
protected Connection _connection;
|
||||
protected int _maxIdleTime;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -55,24 +54,6 @@ public class ByteArrayEndPoint implements ConnectedEndPoint
|
|||
_out=ByteBuffer.allocate(outputSize);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.io.ConnectedEndPoint#getConnection()
|
||||
*/
|
||||
public Connection getConnection()
|
||||
{
|
||||
return _connection;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.io.ConnectedEndPoint#setConnection(org.eclipse.jetty.io.Connection)
|
||||
*/
|
||||
public void setConnection(Connection connection)
|
||||
{
|
||||
_connection=connection;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the in.
|
||||
|
@ -81,6 +62,7 @@ public class ByteArrayEndPoint implements ConnectedEndPoint
|
|||
{
|
||||
return _in;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param in The in to set.
|
||||
|
@ -89,6 +71,7 @@ public class ByteArrayEndPoint implements ConnectedEndPoint
|
|||
{
|
||||
_in = in;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the out.
|
||||
|
@ -97,6 +80,7 @@ public class ByteArrayEndPoint implements ConnectedEndPoint
|
|||
{
|
||||
return _out;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param out The out to set.
|
||||
|
@ -248,59 +232,19 @@ public class ByteArrayEndPoint implements ConnectedEndPoint
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getLocalAddr()
|
||||
*/
|
||||
public String getLocalAddr()
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getLocalHost()
|
||||
*/
|
||||
public String getLocalHost()
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getLocalPort()
|
||||
*/
|
||||
public int getLocalPort()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getRemoteAddr()
|
||||
*/
|
||||
public String getRemoteAddr()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getRemoteHost()
|
||||
*/
|
||||
public String getRemoteHost()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getRemotePort()
|
||||
*/
|
||||
public int getRemotePort()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getConnection()
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
public interface ConnectedEndPoint extends EndPoint
|
||||
{
|
||||
Connection getConnection();
|
||||
void setConnection(Connection connection);
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2006-2009 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Abstract Connection used by Jetty Connectors.
|
||||
* <p>
|
||||
* Jetty will call the handle method of a connection when there is work
|
||||
* to be done on the connection. For blocking connections, this is soon
|
||||
* as the connection is open and handle will keep being called until the
|
||||
* connection is closed. For non-blocking connections, handle will only
|
||||
* be called if there are bytes to be read or the connection becomes writable
|
||||
* after being write blocked.
|
||||
*
|
||||
* @see org.eclipse.jetty.io.nio.SelectorManager
|
||||
*/
|
||||
public interface Connection
|
||||
{
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Handle the connection.
|
||||
* @return The Connection to use for the next handling of the connection.
|
||||
* This allows protocol upgrades and support for CONNECT.
|
||||
* @throws IOException
|
||||
*/
|
||||
Connection handle() throws IOException;
|
||||
|
||||
/**
|
||||
* @return the timestamp at which the connection was created
|
||||
*/
|
||||
long getTimeStamp();
|
||||
|
||||
boolean isIdle();
|
||||
|
||||
boolean isReadInterested();
|
||||
|
||||
/**
|
||||
* Called when the connection is closed
|
||||
*/
|
||||
void onClose();
|
||||
|
||||
/**
|
||||
* Called when the connection idle timeout expires
|
||||
* @param idleForMs TODO
|
||||
*/
|
||||
void onIdleExpired(long idleForMs);
|
||||
}
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
|
@ -76,71 +77,31 @@ public interface EndPoint
|
|||
* @throws EofException If the endpoint is closed or output is shutdown.
|
||||
*/
|
||||
int gather(ByteBuffer... buffer) throws IOException;
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The local Inet address to which this <code>EndPoint</code> is bound, or <code>null</code>
|
||||
* if this <code>EndPoint</code> does not represent a network connection.
|
||||
*/
|
||||
InetSocketAddress getLocalAddress();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The local IP address to which this <code>EndPoint</code> is bound, or <code>null</code>
|
||||
* @return The remote Inet address to which this <code>EndPoint</code> is bound, or <code>null</code>
|
||||
* if this <code>EndPoint</code> does not represent a network connection.
|
||||
*/
|
||||
public String getLocalAddr();
|
||||
InetSocketAddress getRemoteAddress();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The local host name to which this <code>EndPoint</code> is bound, or <code>null</code>
|
||||
* if this <code>EndPoint</code> does not represent a network connection.
|
||||
*/
|
||||
public String getLocalHost();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The local port number on which this <code>EndPoint</code> is listening, or <code>0</code>
|
||||
* if this <code>EndPoint</code> does not represent a network connection.
|
||||
*/
|
||||
public int getLocalPort();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The remote IP address to which this <code>EndPoint</code> is connected, or <code>null</code>
|
||||
* if this <code>EndPoint</code> does not represent a network connection.
|
||||
*/
|
||||
public String getRemoteAddr();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The host name of the remote machine to which this <code>EndPoint</code> is connected, or <code>null</code>
|
||||
* if this <code>EndPoint</code> does not represent a network connection.
|
||||
*/
|
||||
public String getRemoteHost();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The remote port number to which this <code>EndPoint</code> is connected, or <code>0</code>
|
||||
* if this <code>EndPoint</code> does not represent a network connection.
|
||||
*/
|
||||
public int getRemotePort();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean blockReadable(long millisecs) throws IOException;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean blockWritable(long millisecs) throws IOException;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean isOpen();
|
||||
boolean isOpen();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return The underlying transport object (socket, channel, etc.)
|
||||
*/
|
||||
public Object getTransport();
|
||||
Object getTransport();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Flush any buffered output.
|
||||
* May fail to write all data if endpoint is non-blocking
|
||||
* @throws EofException If the endpoint is closed or output is shutdown.
|
||||
*/
|
||||
public void flush() throws IOException;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Get the max idle time in ms.
|
||||
|
@ -151,15 +112,12 @@ public interface EndPoint
|
|||
* to implement the max idle time.
|
||||
* @return the max idle time in ms or if ms <= 0 implies an infinite timeout
|
||||
*/
|
||||
public int getMaxIdleTime();
|
||||
int getMaxIdleTime();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the max idle time.
|
||||
* @param timeMs the max idle time in MS. Timeout <= 0 implies an infinite timeout
|
||||
* @throws IOException if the timeout cannot be set.
|
||||
*/
|
||||
public void setMaxIdleTime(int timeMs) throws IOException;
|
||||
|
||||
|
||||
|
||||
void setMaxIdleTime(int timeMs) throws IOException;
|
||||
}
|
||||
|
|
|
@ -13,13 +13,10 @@
|
|||
|
||||
package org.eclipse.jetty.io.bio;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
|
||||
|
|
|
@ -15,9 +15,41 @@ package org.eclipse.jetty.io.nio;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
|
||||
public interface AsyncConnection extends Connection
|
||||
public interface AsyncConnection
|
||||
{
|
||||
void onInputShutdown() throws IOException;
|
||||
|
||||
AsyncEndPoint getAsyncEndPoint();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Handle the connection.
|
||||
* @return The Connection to use for the next handling of the connection.
|
||||
* This allows protocol upgrades and support for CONNECT.
|
||||
* @throws IOException
|
||||
*/
|
||||
AsyncConnection handle() throws IOException;
|
||||
|
||||
boolean isReadInterested();
|
||||
|
||||
/**
|
||||
* Called when the connection is closed
|
||||
*/
|
||||
void onClose();
|
||||
|
||||
/**
|
||||
* Called when the connection idle timeout expires
|
||||
* @param idleForMs TODO
|
||||
*/
|
||||
void onIdleExpired(long idleForMs);
|
||||
|
||||
|
||||
/**
|
||||
* @return the timestamp at which the connection was created
|
||||
*/
|
||||
long getTimeStamp();
|
||||
|
||||
boolean isIdle();
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.nio.channels.SelectableChannel;
|
|||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
@ -47,6 +45,7 @@ public class ChannelEndPoint implements EndPoint
|
|||
private volatile boolean _ishut;
|
||||
private volatile boolean _oshut;
|
||||
|
||||
|
||||
public ChannelEndPoint(ByteChannel channel) throws IOException
|
||||
{
|
||||
super();
|
||||
|
@ -81,21 +80,12 @@ public class ChannelEndPoint implements EndPoint
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isBlocking()
|
||||
{
|
||||
return !(_channel instanceof SelectableChannel) || ((SelectableChannel)_channel).isBlocking();
|
||||
}
|
||||
|
||||
public boolean blockReadable(long millisecs) throws IOException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean blockWritable(long millisecs) throws IOException
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#isOpen()
|
||||
*/
|
||||
|
@ -278,81 +268,18 @@ public class ChannelEndPoint implements EndPoint
|
|||
return _channel;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getLocalAddr()
|
||||
*/
|
||||
public String getLocalAddr()
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress()
|
||||
{
|
||||
if (_socket==null)
|
||||
return null;
|
||||
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
||||
return StringUtil.ALL_INTERFACES;
|
||||
return _local.getAddress().getHostAddress();
|
||||
return _local;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getLocalHost()
|
||||
*/
|
||||
public String getLocalHost()
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress()
|
||||
{
|
||||
if (_socket==null)
|
||||
return null;
|
||||
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
||||
return StringUtil.ALL_INTERFACES;
|
||||
return _local.getAddress().getCanonicalHostName();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getLocalPort()
|
||||
*/
|
||||
public int getLocalPort()
|
||||
{
|
||||
if (_socket==null)
|
||||
return 0;
|
||||
if (_local==null)
|
||||
return -1;
|
||||
return _local.getPort();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getRemoteAddr()
|
||||
*/
|
||||
public String getRemoteAddr()
|
||||
{
|
||||
if (_socket==null)
|
||||
return null;
|
||||
if (_remote==null)
|
||||
return null;
|
||||
return _remote.getAddress().getHostAddress();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getRemoteHost()
|
||||
*/
|
||||
public String getRemoteHost()
|
||||
{
|
||||
if (_socket==null)
|
||||
return null;
|
||||
if (_remote==null)
|
||||
return null;
|
||||
return _remote.getAddress().getCanonicalHostName();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.io.EndPoint#getRemotePort()
|
||||
*/
|
||||
public int getRemotePort()
|
||||
{
|
||||
if (_socket==null)
|
||||
return 0;
|
||||
return _remote==null?-1:_remote.getPort();
|
||||
return _remote;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -364,12 +291,6 @@ public class ChannelEndPoint implements EndPoint
|
|||
return _channel;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void flush()
|
||||
throws IOException
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public int getMaxIdleTime()
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ import java.nio.channels.SelectionKey;
|
|||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ConnectedEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.io.nio.SelectorManager.SelectSet;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -33,7 +31,7 @@ import org.eclipse.jetty.util.thread.Timeout.Task;
|
|||
/**
|
||||
* An Endpoint that can be scheduled by {@link SelectorManager}.
|
||||
*/
|
||||
public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPoint, ConnectedEndPoint
|
||||
public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPoint
|
||||
{
|
||||
public static final Logger LOG=Log.getLogger("org.eclipse.jetty.io.nio");
|
||||
|
||||
|
@ -48,14 +46,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
/** The desired value for {@link SelectionKey#interestOps()} */
|
||||
private int _interestOps;
|
||||
|
||||
/**
|
||||
* The connection instance is the handler for any IO activity on the endpoint.
|
||||
* There is a different type of connection for HTTP, AJP, WebSocket and
|
||||
* ProxyConnect. The connection may change for an SCEP as it is upgraded
|
||||
* from HTTP to proxy connect or websocket.
|
||||
*/
|
||||
private volatile AsyncConnection _connection;
|
||||
|
||||
/** true if a thread has been dispatched to handle this endpoint */
|
||||
private boolean _dispatched = false;
|
||||
|
||||
|
@ -79,6 +69,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
|
||||
private boolean _ishut;
|
||||
|
||||
private volatile AsyncConnection _connection;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public SelectChannelEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key, int maxIdleTime)
|
||||
throws IOException
|
||||
|
@ -110,19 +102,14 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
return _manager;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Connection getConnection()
|
||||
{
|
||||
return _connection;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setConnection(Connection connection)
|
||||
public void setAsyncConnection(AsyncConnection connection)
|
||||
{
|
||||
Connection old=_connection;
|
||||
_connection=(AsyncConnection)connection;
|
||||
if (old!=null && old!=_connection)
|
||||
_manager.endPointUpgraded(this,old);
|
||||
AsyncConnection old=getAsyncConnection();
|
||||
_connection=connection;
|
||||
if (old!=null && old!=connection)
|
||||
_manager.endPointUpgraded(this,(AsyncConnection)old);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -299,7 +286,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
/* ------------------------------------------------------------ */
|
||||
public void onIdleExpired(long idleForMs)
|
||||
{
|
||||
_connection.onIdleExpired(idleForMs);
|
||||
getAsyncConnection().onIdleExpired(idleForMs);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -480,12 +467,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
return _writable;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public boolean hasProgressed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Updates selection key. Adds operations types to the selection key as needed. No operations
|
||||
|
@ -500,7 +481,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
int current_ops=-1;
|
||||
if (getChannel().isOpen())
|
||||
{
|
||||
boolean read_interest = _readBlocked || (!_dispatched && _connection.isReadInterested());
|
||||
boolean read_interest = _readBlocked || (!_dispatched && getAsyncConnection().isReadInterested());
|
||||
boolean write_interest= _writeBlocked || (!_dispatched && !_writable);
|
||||
|
||||
_interestOps =
|
||||
|
@ -611,12 +592,12 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
{
|
||||
while(true)
|
||||
{
|
||||
final AsyncConnection next = (AsyncConnection)_connection.handle();
|
||||
if (next!=_connection)
|
||||
final AsyncConnection next = (AsyncConnection)getAsyncConnection().handle();
|
||||
if (next!=getAsyncConnection())
|
||||
{
|
||||
LOG.debug("{} replaced {}",next,_connection);
|
||||
Connection old=_connection;
|
||||
_connection=next;
|
||||
LOG.debug("{} replaced {}",next,getAsyncConnection());
|
||||
AsyncConnection old=getAsyncConnection();
|
||||
setAsyncConnection(next);
|
||||
_manager.endPointUpgraded(this,old);
|
||||
continue;
|
||||
}
|
||||
|
@ -652,7 +633,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
_ishut=true;
|
||||
try
|
||||
{
|
||||
_connection.onInputShutdown();
|
||||
getAsyncConnection().onInputShutdown();
|
||||
}
|
||||
catch(Throwable x)
|
||||
{
|
||||
|
@ -744,7 +725,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
_writable,
|
||||
_interestOps,
|
||||
keyString,
|
||||
_connection);
|
||||
getAsyncConnection());
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -764,4 +745,11 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
|
|||
_maxIdleTime=timeMs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public AsyncConnection getAsyncConnection()
|
||||
{
|
||||
return _connection;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ConnectedEndPoint;
|
||||
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;
|
||||
|
@ -341,7 +339,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
protected abstract void endPointOpened(SelectChannelEndPoint endpoint);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected abstract void endPointUpgraded(ConnectedEndPoint endpoint,Connection oldConnection);
|
||||
protected abstract void endPointUpgraded(EndPoint endpoint,AsyncConnection oldConnection);
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public abstract AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment);
|
||||
|
|
|
@ -14,17 +14,18 @@
|
|||
package org.eclipse.jetty.io.nio;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
import org.eclipse.jetty.io.AbstractAsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -40,7 +41,7 @@ import org.eclipse.jetty.util.thread.Timeout.Task;
|
|||
* it's source/sink of encrypted data. It then provides {@link #getSslEndPoint()} to
|
||||
* expose a source/sink of unencrypted data to another connection (eg HttpConnection).
|
||||
*/
|
||||
public class SslConnection extends AbstractConnection implements AsyncConnection
|
||||
public class SslConnection extends AbstractAsyncConnection
|
||||
{
|
||||
private final Logger _logger = Log.getLogger("org.eclipse.jetty.io.nio.ssl");
|
||||
|
||||
|
@ -102,6 +103,12 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
return new SslEndPoint();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public AsyncEndPoint getAsyncEndPoint()
|
||||
{
|
||||
return _aEndp;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if SSL re-negotiation is allowed (default false)
|
||||
|
@ -175,7 +182,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -557,7 +564,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
return _engine;
|
||||
}
|
||||
|
||||
public AsyncEndPoint getEndpoint()
|
||||
public AsyncEndPoint getIoEndPoint()
|
||||
{
|
||||
return _aEndp;
|
||||
}
|
||||
|
@ -649,7 +656,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
{
|
||||
if (process(null,null))
|
||||
break;
|
||||
_endp.blockReadable(end-now);
|
||||
_aEndp.blockReadable(end-now);
|
||||
now = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
@ -658,7 +665,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
|
||||
public boolean blockWritable(long millisecs) throws IOException
|
||||
{
|
||||
return _endp.blockWritable(millisecs);
|
||||
return _aEndp.blockWritable(millisecs);
|
||||
}
|
||||
|
||||
public boolean isOpen()
|
||||
|
@ -716,39 +723,14 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
return _aEndp.isWritable();
|
||||
}
|
||||
|
||||
public boolean hasProgressed()
|
||||
public InetSocketAddress getLocalAddress()
|
||||
{
|
||||
return _progressed.getAndSet(false);
|
||||
return _aEndp.getLocalAddress();
|
||||
}
|
||||
|
||||
public String getLocalAddr()
|
||||
public InetSocketAddress getRemoteAddress()
|
||||
{
|
||||
return _aEndp.getLocalAddr();
|
||||
}
|
||||
|
||||
public String getLocalHost()
|
||||
{
|
||||
return _aEndp.getLocalHost();
|
||||
}
|
||||
|
||||
public int getLocalPort()
|
||||
{
|
||||
return _aEndp.getLocalPort();
|
||||
}
|
||||
|
||||
public String getRemoteAddr()
|
||||
{
|
||||
return _aEndp.getRemoteAddr();
|
||||
}
|
||||
|
||||
public String getRemoteHost()
|
||||
{
|
||||
return _aEndp.getRemoteHost();
|
||||
}
|
||||
|
||||
public int getRemotePort()
|
||||
{
|
||||
return _aEndp.getRemotePort();
|
||||
return _aEndp.getRemoteAddress();
|
||||
}
|
||||
|
||||
public boolean isBlocking()
|
||||
|
@ -765,13 +747,13 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
{
|
||||
_aEndp.setMaxIdleTime(timeMs);
|
||||
}
|
||||
|
||||
public Connection getConnection()
|
||||
|
||||
public AsyncConnection getAsyncConnection()
|
||||
{
|
||||
return _connection;
|
||||
}
|
||||
|
||||
public void setConnection(Connection connection)
|
||||
public void setAsyncConnection(AsyncConnection connection)
|
||||
{
|
||||
_connection=(AsyncConnection)connection;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,8 @@ import java.net.SocketException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.AsynchronousServerSocketChannel;
|
||||
import java.nio.channels.AsynchronousSocketChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.eclipse.jetty.io.nio;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
|
@ -48,7 +49,7 @@ public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
|
|||
SslConnection connection = new SslConnection(engine,endpoint);
|
||||
|
||||
AsyncConnection delegate = super.newConnection(channel,connection.getSslEndPoint());
|
||||
connection.getSslEndPoint().setConnection(delegate);
|
||||
connection.getSslEndPoint().setAsyncConnection(delegate);
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.eclipse.jetty.io.nio;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -21,13 +20,11 @@ import java.nio.channels.SocketChannel;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
import org.eclipse.jetty.io.AbstractAsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ConnectedEndPoint;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -58,7 +55,7 @@ public class SelectChannelEndPointTest
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void endPointUpgraded(ConnectedEndPoint endpoint, org.eclipse.jetty.io.Connection oldConnection)
|
||||
protected void endPointUpgraded(EndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -72,7 +69,7 @@ public class SelectChannelEndPointTest
|
|||
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException
|
||||
{
|
||||
SelectChannelEndPoint endp = new SelectChannelEndPoint(channel,selectSet,key,2000);
|
||||
endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment()));
|
||||
endp.setAsyncConnection(selectSet.getManager().newConnection(channel,endp, key.attachment()));
|
||||
_lastEndp=endp;
|
||||
return endp;
|
||||
}
|
||||
|
@ -108,7 +105,7 @@ public class SelectChannelEndPointTest
|
|||
return new TestConnection(endpoint);
|
||||
}
|
||||
|
||||
public class TestConnection extends AbstractConnection implements AsyncConnection
|
||||
public class TestConnection extends AbstractAsyncConnection implements AsyncConnection
|
||||
{
|
||||
ByteBuffer _in = BufferUtil.allocate(32*1024);
|
||||
ByteBuffer _out = BufferUtil.allocate(32*1024);
|
||||
|
@ -118,7 +115,7 @@ public class SelectChannelEndPointTest
|
|||
super(endp);
|
||||
}
|
||||
|
||||
public org.eclipse.jetty.io.Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
boolean progress=true;
|
||||
while(progress)
|
||||
|
@ -133,7 +130,7 @@ public class SelectChannelEndPointTest
|
|||
|
||||
while (_blockAt>0 && _in.remaining()>0 && _in.remaining()<_blockAt)
|
||||
{
|
||||
_endp.blockReadable(10000);
|
||||
((AsyncEndPoint)_endp).blockReadable(10000);
|
||||
if (!BufferUtil.isFull(_in) && _endp.fill(_in)>0)
|
||||
progress=true;
|
||||
}
|
||||
|
@ -163,6 +160,12 @@ public class SelectChannelEndPointTest
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncEndPoint getAsyncEndPoint()
|
||||
{
|
||||
return (AsyncEndPoint)getEndPoint();
|
||||
}
|
||||
|
||||
public void onClose()
|
||||
{
|
||||
// System.err.println("onClose");
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.jetty.util.component.Container.Relationship;
|
|||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.eclipse.jetty.util.thread.ShutdownThread;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.net.InetAddress;
|
|||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
import org.eclipse.jetty.http.HttpBuffers;
|
||||
|
@ -27,10 +28,9 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpScheme;
|
||||
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.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.io.nio.AsyncConnection;
|
||||
import org.eclipse.jetty.util.component.AggregateLifeCycle;
|
||||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -1125,7 +1125,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Ht
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void connectionOpened(Connection connection)
|
||||
protected void connectionOpened(AsyncConnection connection)
|
||||
{
|
||||
if (_statsStartedAt.get() == -1)
|
||||
return;
|
||||
|
@ -1134,13 +1134,13 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Ht
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void connectionUpgraded(Connection oldConnection, Connection newConnection)
|
||||
protected void connectionUpgraded(AsyncConnection oldConnection, AsyncConnection newConnection)
|
||||
{
|
||||
_requestStats.set((oldConnection instanceof AbstractHttpConnection)?((AbstractHttpConnection)oldConnection).getRequests():0);
|
||||
_requestStats.set((oldConnection instanceof HttpConnection)?((HttpConnection)oldConnection).getHttpChannel().getRequests():0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void connectionClosed(Connection connection)
|
||||
protected void connectionClosed(AsyncConnection connection)
|
||||
{
|
||||
connection.onClose();
|
||||
|
||||
|
@ -1148,7 +1148,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Ht
|
|||
return;
|
||||
|
||||
long duration = System.currentTimeMillis() - connection.getTimeStamp();
|
||||
int requests = (connection instanceof AbstractHttpConnection)?((AbstractHttpConnection)connection).getRequests():0;
|
||||
int requests = (connection instanceof HttpConnection)?((HttpConnection)connection).getHttpChannel().getRequests():0;
|
||||
_requestStats.set(requests);
|
||||
_connectionStats.decrement();
|
||||
_connectionDurationStats.set(duration);
|
||||
|
|
|
@ -13,24 +13,21 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.ServletResponseWrapper;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.ServletResponseWrapper;
|
||||
|
||||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationThrowable;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.continuation.ContinuationThrowable;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler.Context;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -113,7 +113,7 @@ public class Dispatcher implements RequestDispatcher
|
|||
*/
|
||||
public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
|
||||
Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentHttpChannel().getRequest();
|
||||
|
||||
|
||||
if (!(request instanceof HttpServletRequest))
|
||||
|
@ -194,7 +194,7 @@ public class Dispatcher implements RequestDispatcher
|
|||
*/
|
||||
protected void forward(ServletRequest request, ServletResponse response, DispatcherType dispatch) throws ServletException, IOException
|
||||
{
|
||||
Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
|
||||
Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentHttpChannel().getRequest();
|
||||
Response base_response=baseRequest.getResponse();
|
||||
response.resetBuffer();
|
||||
base_response.fwdReset();
|
||||
|
|
|
@ -47,10 +47,10 @@ public interface Handler extends LifeCycle, Destroyable
|
|||
* @param target The target of the request - either a URI or a name.
|
||||
* @param baseRequest The original unwrapped request object.
|
||||
* @param request The request either as the {@link Request}
|
||||
* object or a wrapper of that request. The {@link AbstractHttpConnection#getCurrentConnection()}
|
||||
* object or a wrapper of that request. The {@link AbstractHttpConnection#getCurrentHttpChannel()}
|
||||
* method can be used access the Request object if required.
|
||||
* @param response The response as the {@link Response}
|
||||
* object or a wrapper of that request. The {@link AbstractHttpConnection#getCurrentConnection()}
|
||||
* object or a wrapper of that request. The {@link AbstractHttpConnection#getCurrentHttpChannel()}
|
||||
* method can be used access the Response object if required.
|
||||
* @throws IOException
|
||||
* @throws ServletException
|
||||
|
|
|
@ -17,9 +17,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.ServletInputStream;
|
||||
|
@ -27,33 +25,21 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.continuation.ContinuationThrowable;
|
||||
import org.eclipse.jetty.http.HttpBuffers;
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.http.HttpException;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpParser.RequestHandler;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
|
||||
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;
|
||||
import org.eclipse.jetty.io.UncheckedPrintWriter;
|
||||
import org.eclipse.jetty.server.HttpServerTestBase.AvailableHandler;
|
||||
import org.eclipse.jetty.server.nio.NIOConnector;
|
||||
import org.eclipse.jetty.server.ssl.SslConnector;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -67,8 +53,20 @@ public class HttpChannel
|
|||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpChannel.class);
|
||||
|
||||
private static final ThreadLocal<HttpChannel> __currentConnection = new ThreadLocal<HttpChannel>();
|
||||
private static final ThreadLocal<HttpChannel> __currentChannel = new ThreadLocal<HttpChannel>();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static HttpChannel getCurrentHttpChannel()
|
||||
{
|
||||
return __currentChannel.get();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected static void setCurrentHttpChannel(HttpChannel channel)
|
||||
{
|
||||
__currentChannel.set(channel);
|
||||
}
|
||||
|
||||
private int _requests;
|
||||
|
||||
protected final Server _server;
|
||||
|
@ -94,17 +92,56 @@ public class HttpChannel
|
|||
private boolean _expect102Processing = false;
|
||||
private boolean _host = false;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public static HttpChannel getCurrentConnection()
|
||||
public HttpParser.RequestHandler getRequestHandler()
|
||||
{
|
||||
return __currentConnection.get();
|
||||
return _handler;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected static void setCurrentConnection(HttpChannel connection)
|
||||
public HttpGenerator.ResponseInfo getResponseInfo()
|
||||
{
|
||||
__currentConnection.set(connection);
|
||||
return _info;
|
||||
}
|
||||
|
||||
private final RequestHandler _handler = new RequestHandler();
|
||||
private final HttpGenerator.ResponseInfo _info = new HttpGenerator.ResponseInfo()
|
||||
{
|
||||
@Override
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return getRequest().getHttpVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpFields getHttpFields()
|
||||
{
|
||||
return _responseFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentLength()
|
||||
{
|
||||
return _response.getLongContentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHead()
|
||||
{
|
||||
return getRequest().isHead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatus()
|
||||
{
|
||||
return _response.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReason()
|
||||
{
|
||||
return _response.getReason();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Constructor
|
||||
|
@ -420,7 +457,7 @@ public class HttpChannel
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @see org.eclipse.jetty.io.Connection#isSuspended()
|
||||
* @see org.eclipse.jetty.io.AsyncConnection#isSuspended()
|
||||
*/
|
||||
public boolean isSuspended()
|
||||
{
|
||||
|
@ -767,13 +804,12 @@ public class HttpChannel
|
|||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void send1xx(int processing102)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean isAllContentWritten()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -832,12 +868,6 @@ public class HttpChannel
|
|||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMaxIdleTime()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void flushResponse()
|
||||
{
|
||||
|
@ -866,7 +896,6 @@ public class HttpChannel
|
|||
public void cancelTimeout(Task timeout)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -907,54 +936,5 @@ public class HttpChannel
|
|||
}
|
||||
|
||||
|
||||
public HttpParser.RequestHandler getRequestHandler()
|
||||
{
|
||||
return _handler;
|
||||
}
|
||||
|
||||
public HttpGenerator.ResponseInfo getResponseInfo()
|
||||
{
|
||||
return _info;
|
||||
}
|
||||
|
||||
private final RequestHandler _handler = new RequestHandler();
|
||||
private final HttpGenerator.ResponseInfo _info = new HttpGenerator.ResponseInfo()
|
||||
{
|
||||
@Override
|
||||
public HttpVersion getHttpVersion()
|
||||
{
|
||||
return getRequest().getHttpVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpFields getHttpFields()
|
||||
{
|
||||
return _responseFields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentLength()
|
||||
{
|
||||
return _response.getLongContentLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHead()
|
||||
{
|
||||
return getRequest().isHead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatus()
|
||||
{
|
||||
return _response.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReason()
|
||||
{
|
||||
return _response.getReason();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -14,64 +14,35 @@
|
|||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.continuation.ContinuationThrowable;
|
||||
import org.eclipse.jetty.http.HttpBuffers;
|
||||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.http.HttpException;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpGenerator.Action;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.http.HttpGenerator.Action;
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
|
||||
import org.eclipse.jetty.io.AbstractAsyncConnection;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
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;
|
||||
import org.eclipse.jetty.io.UncheckedPrintWriter;
|
||||
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
|
||||
import org.eclipse.jetty.server.nio.NIOConnector;
|
||||
import org.eclipse.jetty.server.ssl.SslConnector;
|
||||
import org.eclipse.jetty.io.nio.AsyncConnection;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class HttpConnection extends AbstractConnection
|
||||
public abstract class HttpConnection extends AbstractAsyncConnection
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(HttpConnection.class);
|
||||
|
||||
private static final ThreadLocal<HttpConnection> __currentConnection = new ThreadLocal<HttpConnection>();
|
||||
|
||||
private final AsyncEndPoint _asyncEndp;
|
||||
private final Server _server;
|
||||
private final Connector _connector;
|
||||
private final HttpParser _parser;
|
||||
|
@ -100,12 +71,11 @@ public abstract class HttpConnection extends AbstractConnection
|
|||
/** Constructor
|
||||
*
|
||||
*/
|
||||
public HttpConnection(Connector connector, EndPoint endpoint, Server server)
|
||||
public HttpConnection(Connector connector, AsyncEndPoint endpoint, Server server)
|
||||
{
|
||||
super(endpoint);
|
||||
_connector = connector;
|
||||
_server = server;
|
||||
_asyncEndp=(AsyncEndPoint)endpoint;
|
||||
|
||||
_channel = new HttpChannel(server);
|
||||
|
||||
|
@ -139,6 +109,15 @@ public abstract class HttpConnection extends AbstractConnection
|
|||
return _connector;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Returns the HttpChannel.
|
||||
*/
|
||||
public HttpChannel getHttpChannel()
|
||||
{
|
||||
return _channel;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void reset()
|
||||
{
|
||||
|
@ -200,9 +179,9 @@ public abstract class HttpConnection extends AbstractConnection
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
Connection connection = this;
|
||||
AsyncConnection connection = this;
|
||||
boolean progress=true;
|
||||
|
||||
try
|
||||
|
@ -210,7 +189,7 @@ public abstract class HttpConnection extends AbstractConnection
|
|||
setCurrentConnection(this);
|
||||
|
||||
// don't check for idle while dispatched (unless blocking IO is done).
|
||||
_asyncEndp.setCheckForIdle(false);
|
||||
getAsyncEndPoint().setCheckForIdle(false);
|
||||
|
||||
|
||||
// While progress and the connection has not changed
|
||||
|
@ -254,7 +233,7 @@ public abstract class HttpConnection extends AbstractConnection
|
|||
// look for a switched connection instance?
|
||||
if (_channel.getResponse().getStatus()==HttpStatus.SWITCHING_PROTOCOLS_101)
|
||||
{
|
||||
Connection switched=(Connection)_channel.getRequest().getAttribute("org.eclipse.jetty.io.Connection");
|
||||
AsyncConnection switched=(AsyncConnection)_channel.getRequest().getAttribute("org.eclipse.jetty.io.Connection");
|
||||
if (switched!=null)
|
||||
connection=switched;
|
||||
}
|
||||
|
@ -281,7 +260,7 @@ public abstract class HttpConnection extends AbstractConnection
|
|||
if (!_channel.getRequest().getAsyncContinuation().isAsyncStarted())
|
||||
{
|
||||
// reenable idle checking unless request is suspended
|
||||
_asyncEndp.setCheckForIdle(true);
|
||||
getAsyncEndPoint().setCheckForIdle(true);
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
|
@ -289,101 +268,75 @@ public abstract class HttpConnection extends AbstractConnection
|
|||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private void write(ByteBuffer content, Action action) throws IOException
|
||||
private void generate(ByteBuffer content, Action action) throws IOException
|
||||
{
|
||||
if (!_generator.isComplete())
|
||||
throw new EofException();
|
||||
|
||||
try
|
||||
while(BufferUtil.hasContent(content))
|
||||
{
|
||||
while(BufferUtil.hasContent(content))
|
||||
{
|
||||
/* System.err.printf("generate(%s,%s,%s,%s,%s)@%s%n",
|
||||
BufferUtil.toSummaryString(header),
|
||||
BufferUtil.toSummaryString(chunk),
|
||||
BufferUtil.toSummaryString(buffer),
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{}: generate({},{},{},{},{})@{}",
|
||||
this,
|
||||
BufferUtil.toSummaryString(_responseHeader),
|
||||
BufferUtil.toSummaryString(_chunk),
|
||||
BufferUtil.toSummaryString(_responseBuffer),
|
||||
BufferUtil.toSummaryString(content),
|
||||
action,gen.getState());*/
|
||||
HttpGenerator.Result result=_generator.generate(_responseHeader,_chunk,_responseBuffer,content,action);
|
||||
/*System.err.printf("%s (%s,%s,%s,%s,%s)@%s%n",
|
||||
action,_generator.getState());
|
||||
|
||||
HttpGenerator.Result result=_generator.generate(_responseHeader,_chunk,_responseBuffer,content,action);
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{}: {} ({},{},{},{},{})@{}",
|
||||
this,
|
||||
result,
|
||||
BufferUtil.toSummaryString(header),
|
||||
BufferUtil.toSummaryString(chunk),
|
||||
BufferUtil.toSummaryString(buffer),
|
||||
BufferUtil.toSummaryString(_responseHeader),
|
||||
BufferUtil.toSummaryString(_chunk),
|
||||
BufferUtil.toSummaryString(_responseBuffer),
|
||||
BufferUtil.toSummaryString(content),
|
||||
action,gen.getState());*/
|
||||
action,_generator.getState());
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case NEED_HEADER:
|
||||
_responseHeader=_connector.getResponseBuffers().getHeader();
|
||||
break;
|
||||
switch(result)
|
||||
{
|
||||
case NEED_HEADER:
|
||||
_responseHeader=_connector.getResponseBuffers().getHeader();
|
||||
break;
|
||||
|
||||
case NEED_BUFFER:
|
||||
_responseBuffer=_connector.getResponseBuffers().getBuffer();
|
||||
_responseBuffer=BufferUtil.allocate(8192);
|
||||
break;
|
||||
case NEED_BUFFER:
|
||||
_responseBuffer=_connector.getResponseBuffers().getBuffer();
|
||||
_responseBuffer=BufferUtil.allocate(8192);
|
||||
break;
|
||||
|
||||
case NEED_CHUNK:
|
||||
_responseHeader=null;
|
||||
_chunk=_connector.getResponseBuffers().getBuffer(HttpGenerator.CHUNK_SIZE);
|
||||
break;
|
||||
case NEED_CHUNK:
|
||||
_responseHeader=null;
|
||||
_chunk=_connector.getResponseBuffers().getBuffer(HttpGenerator.CHUNK_SIZE);
|
||||
break;
|
||||
|
||||
case FLUSH:
|
||||
{
|
||||
Future<Integer> future = getEndPoint().flush(_responseHeader,_chunk,_responseBuffer);
|
||||
future.get(getMaxIdleTime(),TimeUnit.MILLISECONDS);
|
||||
break;
|
||||
}
|
||||
case FLUSH_CONTENT:
|
||||
{
|
||||
Future<Integer> future = getEndPoint().flush(_responseHeader,_chunk,content);
|
||||
future.get(getMaxIdleTime(),TimeUnit.MILLISECONDS);
|
||||
break;
|
||||
}
|
||||
case OK:
|
||||
break;
|
||||
case SHUTDOWN_OUT:
|
||||
getEndPoint().shutdownOutput();
|
||||
break;
|
||||
}
|
||||
case FLUSH:
|
||||
getAsyncEndPoint().gather(_responseHeader,_chunk,_responseBuffer);
|
||||
// TODO handle incomplete flush
|
||||
break;
|
||||
|
||||
switch(action)
|
||||
{
|
||||
case COMPLETE: action=Action.PREPARE; break;
|
||||
case FLUSH: action=Action.FLUSH; break;
|
||||
case PREPARE: action=Action.PREPARE; break;
|
||||
}
|
||||
case FLUSH_CONTENT:
|
||||
getAsyncEndPoint().gather(_responseHeader,_chunk,content);
|
||||
// TODO handle incomplete flush
|
||||
break;
|
||||
|
||||
case SHUTDOWN_OUT:
|
||||
getAsyncEndPoint().shutdownOutput();
|
||||
break;
|
||||
case OK:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(action)
|
||||
{
|
||||
case COMPLETE: action=Action.PREPARE; break;
|
||||
case FLUSH: action=Action.FLUSH; break;
|
||||
case PREPARE: action=Action.PREPARE; break;
|
||||
}
|
||||
}
|
||||
|
||||
catch(final TimeoutException e)
|
||||
{
|
||||
throw new InterruptedIOException(e.toString())
|
||||
{
|
||||
{
|
||||
this.initCause(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (final InterruptedException e)
|
||||
{
|
||||
throw new InterruptedIOException(e.toString())
|
||||
{
|
||||
{
|
||||
this.initCause(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (final ExecutionException e)
|
||||
{
|
||||
throw new IOException(e.toString())
|
||||
{
|
||||
{
|
||||
this.initCause(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.nio.ByteBuffer;
|
|||
|
||||
import javax.servlet.ServletInputStream;
|
||||
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
||||
|
||||
|
|
|
@ -14,23 +14,11 @@
|
|||
package org.eclipse.jetty.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.Writer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.CompletionHandler;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpGenerator.Action;
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.ByteArrayOutputStream2;
|
||||
|
||||
/** Output.
|
||||
|
|
|
@ -19,9 +19,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -108,7 +106,7 @@ public class LocalConnector extends AbstractConnector
|
|||
ByteArrayEndPoint endPoint = new ByteArrayEndPoint(_requestsBuffer.asArray(), 1024)
|
||||
{
|
||||
@Override
|
||||
public void setConnection(Connection connection)
|
||||
public void setConnection(AsyncConnection connection)
|
||||
{
|
||||
if (getConnection()!=null && connection!=getConnection())
|
||||
connectionUpgraded(getConnection(),connection);
|
||||
|
@ -128,8 +126,8 @@ public class LocalConnector extends AbstractConnector
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
final Connection con = endPoint.getConnection();
|
||||
final Connection next = con.handle();
|
||||
final AsyncConnection con = endPoint.getConnection();
|
||||
final AsyncConnection next = con.handle();
|
||||
if (next!=con)
|
||||
{
|
||||
endPoint.setConnection(next);
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.InputStreamReader;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
|
@ -37,7 +36,6 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
|
@ -58,20 +56,13 @@ import javax.servlet.http.Part;
|
|||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.eclipse.jetty.http.HttpException;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler.Context;
|
||||
import org.eclipse.jetty.util.Attributes;
|
||||
|
@ -331,9 +322,6 @@ public class Request implements HttpServletRequest
|
|||
*/
|
||||
public Object getAttribute(String name)
|
||||
{
|
||||
if ("org.eclipse.jetty.io.EndPoint.maxIdleTime".equalsIgnoreCase(name))
|
||||
return new Long(_connection.getMaxIdleTime());
|
||||
|
||||
Object attr = (_attributes == null)?null:_attributes.getAttribute(name);
|
||||
if (attr == null && Continuation.ATTRIBUTE.equals(name))
|
||||
return _async;
|
||||
|
@ -1481,7 +1469,7 @@ public class Request implements HttpServletRequest
|
|||
{
|
||||
try
|
||||
{
|
||||
((AbstractHttpConnection.Output)getServletResponse().getOutputStream()).sendContent(value);
|
||||
((HttpChannel.Output)getServletResponse().getOutputStream()).sendContent(value);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -1495,7 +1483,7 @@ public class Request implements HttpServletRequest
|
|||
final ByteBuffer byteBuffer = (ByteBuffer)value;
|
||||
synchronized (byteBuffer)
|
||||
{
|
||||
((AbstractHttpConnection.Output)getServletResponse().getOutputStream()).sendResponse(byteBuffer);
|
||||
((HttpChannel.Output)getServletResponse().getOutputStream()).sendResponse(byteBuffer);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
|
@ -1578,12 +1566,6 @@ public class Request implements HttpServletRequest
|
|||
_characterEncoding = encoding;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
// final so we can safely call this from constructor
|
||||
protected final void setConnection(AbstractHttpConnection connection)
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see javax.servlet.ServletRequest#getContentType()
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.Comparator;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
@ -29,7 +28,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import org.eclipse.jetty.http.HttpContent;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.io.PrintWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
@ -27,9 +26,8 @@ import javax.servlet.http.HttpSession;
|
|||
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
|
@ -38,7 +36,6 @@ import org.eclipse.jetty.http.MimeTypes;
|
|||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.ErrorHandler;
|
||||
import org.eclipse.jetty.util.ByteArrayISO8859Writer;
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.eclipse.jetty.server.handler;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
@ -18,15 +19,9 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
|
||||
import org.eclipse.jetty.io.ConnectedEndPoint;
|
||||
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.io.nio.SelectorManager;
|
||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -233,7 +228,7 @@ public class ConnectHandler extends HandlerWrapper
|
|||
// 1. when this unread data is written and the server replies before the clientToProxy
|
||||
// connection is installed (it is only installed after returning from this method)
|
||||
// 2. when the client sends data before this unread data has been written.
|
||||
AbstractHttpConnection httpConnection = AbstractHttpConnection.getCurrentConnection();
|
||||
AbstractHttpConnection httpConnection = AbstractHttpConnection.getCurrentHttpChannel();
|
||||
ByteBuffer headerBuffer = ((HttpParser)httpConnection.getParser()).getHeaderBuffer();
|
||||
ByteBuffer bodyBuffer = ((HttpParser)httpConnection.getParser()).getBodyBuffer();
|
||||
int length = headerBuffer == null ? 0 : headerBuffer.length();
|
||||
|
@ -273,7 +268,7 @@ public class ConnectHandler extends HandlerWrapper
|
|||
|
||||
private ClientToProxyConnection prepareConnections(ConcurrentMap<String, Object> context, SocketChannel channel, ByteBuffer buffer)
|
||||
{
|
||||
AbstractHttpConnection httpConnection = AbstractHttpConnection.getCurrentConnection();
|
||||
AbstractHttpConnection httpConnection = AbstractHttpConnection.getCurrentHttpChannel();
|
||||
ProxyToServerConnection proxyToServer = newProxyToServerConnection(context, buffer);
|
||||
ClientToProxyConnection clientToProxy = newClientToProxyConnection(context, channel, httpConnection.getEndPoint(), httpConnection.getTimeStamp());
|
||||
clientToProxy.setConnection(proxyToServer);
|
||||
|
@ -354,7 +349,7 @@ public class ConnectHandler extends HandlerWrapper
|
|||
{
|
||||
}
|
||||
|
||||
private void upgradeConnection(HttpServletRequest request, HttpServletResponse response, Connection connection) throws IOException
|
||||
private void upgradeConnection(HttpServletRequest request, HttpServletResponse response, AsyncConnection connection) throws IOException
|
||||
{
|
||||
// Set the new connection as request attribute and change the status to 101
|
||||
// so that Jetty understands that it has to upgrade the connection
|
||||
|
@ -459,7 +454,7 @@ public class ConnectHandler extends HandlerWrapper
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection)
|
||||
protected void endPointUpgraded(ConnectedEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -491,7 +486,7 @@ public class ConnectHandler extends HandlerWrapper
|
|||
return builder.append(")").toString();
|
||||
}
|
||||
|
||||
public Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
_logger.debug("{}: begin reading from server", this);
|
||||
try
|
||||
|
@ -708,7 +703,7 @@ public class ConnectHandler extends HandlerWrapper
|
|||
return builder.append(")").toString();
|
||||
}
|
||||
|
||||
public Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
_logger.debug("{}: begin reading from client", this);
|
||||
try
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.io.InputStream;
|
|||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.AccessController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -31,9 +32,11 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterRegistration;
|
||||
import javax.servlet.FilterRegistration.Dynamic;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -48,17 +51,12 @@ import javax.servlet.ServletRequestEvent;
|
|||
import javax.servlet.ServletRequestListener;
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterRegistration;
|
||||
import javax.servlet.FilterRegistration.Dynamic;
|
||||
import javax.servlet.descriptor.JspConfigDescriptor;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.http.HttpException;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
|
||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.HandlerContainer;
|
||||
|
@ -879,7 +877,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
|
|||
// Check the connector
|
||||
if (_connectors != null && _connectors.size() > 0)
|
||||
{
|
||||
String connector = AbstractHttpConnection.getCurrentConnection().getConnector().getName();
|
||||
String connector = AbstractHttpConnection.getCurrentHttpChannel().getConnector().getName();
|
||||
if (connector == null || !_connectors.contains(connector))
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.ByteArrayISO8859Writer;
|
||||
|
||||
|
@ -45,7 +44,7 @@ public class ErrorHandler extends AbstractHandler
|
|||
*/
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||
{
|
||||
AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection();
|
||||
AbstractHttpConnection connection = AbstractHttpConnection.getCurrentHttpChannel();
|
||||
connection.getRequest().setHandled(true);
|
||||
String method = request.getMethod();
|
||||
if(!method.equals(HttpMethod.GET) && !method.equals(HttpMethod.POST) && !method.equals(HttpMethod.HEAD))
|
||||
|
|
|
@ -25,7 +25,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.PathMap;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.IPAddressMap;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.jetty.server.handler;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -26,10 +27,7 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.MimeTypes;
|
||||
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.WriterOutputStream;
|
||||
import org.eclipse.jetty.server.AbstractHttpConnection;
|
||||
import org.eclipse.jetty.server.Dispatcher;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
|
|
|
@ -22,14 +22,10 @@ import java.nio.channels.SocketChannel;
|
|||
|
||||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||
import org.eclipse.jetty.io.ConnectedEndPoint;
|
||||
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.io.nio.SelectorManager;
|
||||
import org.eclipse.jetty.io.nio.SelectorManager.SelectSet;
|
||||
import org.eclipse.jetty.server.AsyncHttpConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
||||
|
@ -300,7 +296,7 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection)
|
||||
protected void endPointUpgraded(ConnectedEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
connectionUpgraded(oldConnection,endpoint.getConnection());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -37,8 +36,6 @@ import javax.servlet.http.HttpSessionEvent;
|
|||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.eclipse.jetty.server.AbstractConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.SessionIdManager;
|
||||
import org.eclipse.jetty.server.SessionManager;
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.ObjectInputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
|
@ -28,11 +28,9 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
|
|
@ -10,7 +10,6 @@ import javax.net.ssl.SSLSocket;
|
|||
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.bio.SocketEndPoint;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
|
|
@ -28,8 +28,6 @@ import org.eclipse.jetty.io.Buffers.Type;
|
|||
import org.eclipse.jetty.io.BuffersFactory;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.RuntimeIOException;
|
||||
import org.eclipse.jetty.io.bio.SocketEndPoint;
|
||||
import org.eclipse.jetty.io.nio.AsyncConnection;
|
||||
import org.eclipse.jetty.io.nio.SslConnection;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
|
|
|
@ -28,7 +28,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
|
@ -60,7 +59,7 @@ public class AbstractConnectorTest
|
|||
_server = new Server();
|
||||
_connector = new SelectChannelConnector()
|
||||
{
|
||||
public void connectionClosed(Connection connection)
|
||||
public void connectionClosed(AsyncConnection connection)
|
||||
{
|
||||
super.connectionClosed(connection);
|
||||
_closed.countDown();
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.net.Socket;
|
|||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
|
@ -30,8 +31,6 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.toolchain.test.Stress;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import org.eclipse.jetty.server.nio.BlockingChannelConnector;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import org.eclipse.jetty.server.nio.BlockingChannelConnector;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import org.eclipse.jetty.server.nio.BlockingChannelConnector;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.BeforeClass;
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -20,6 +24,7 @@ import java.net.Socket;
|
|||
import java.net.SocketException;
|
||||
import java.util.concurrent.Exchanger;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -32,10 +37,6 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
{
|
||||
protected static final int MAX_IDLE_TIME=250;
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -25,6 +31,7 @@ import java.net.URL;
|
|||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Exchanger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -32,7 +39,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
@ -41,12 +47,6 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -10,8 +10,6 @@ import java.net.Socket;
|
|||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
|
@ -4,15 +4,12 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.http.AbstractGenerator;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpGenerator;
|
||||
|
||||
import org.eclipse.jetty.io.Buffers;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.SimpleBuffers;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
|
@ -79,7 +76,7 @@ public class HttpWriterTest
|
|||
AbstractHttpConnection connection = new AbstractHttpConnection(null,endp,new Server(),null,generator,null)
|
||||
{
|
||||
@Override
|
||||
public Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -172,7 +169,7 @@ public class HttpWriterTest
|
|||
AbstractHttpConnection connection = new AbstractHttpConnection(null,endp,new Server(),null,hb,null)
|
||||
{
|
||||
@Override
|
||||
public Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,19 +17,11 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.servlet.AsyncContext;
|
||||
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.server.session.SessionHandler;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -30,7 +31,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
import org.eclipse.jetty.io.NetworkTrafficListener;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.nio.NetworkTrafficSelectChannelConnector;
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.io.Reader;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
|
|
@ -35,15 +35,10 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSessionContext;
|
||||
|
||||
import org.eclipse.jetty.http.Generator;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.Parser;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.ByteArrayEndPoint;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.session.AbstractSession;
|
||||
|
@ -513,7 +508,7 @@ public class ResponseTest
|
|||
endPoint.setGrowOutput(true);
|
||||
AbstractHttpConnection connection=new TestHttpConnection(connector, endPoint, connector.getServer());
|
||||
connection.getGenerator().reset();
|
||||
AbstractHttpConnection.setCurrentConnection(connection);
|
||||
AbstractHttpConnection.setCurrentHttpChannel(connection);
|
||||
Response response = connection.getResponse();
|
||||
connection.getRequest().setRequestURI("/test");
|
||||
return response;
|
||||
|
@ -627,7 +622,7 @@ public class ResponseTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public Connection handle() throws IOException
|
||||
public AsyncConnection handle() throws IOException
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.junit.Before;
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
// ========================================================================
|
||||
|
||||
package org.eclipse.jetty.server;
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public class SocketTimeoutTest extends ConnectorTimeoutTest
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
@ -16,9 +19,6 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.junit.AfterClass;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @version $Revision$ $Date$
|
||||
*/
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
|
@ -18,7 +19,6 @@ import javax.servlet.ServletOutputStream;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
|
|
|
@ -14,17 +14,23 @@
|
|||
|
||||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
|
@ -32,10 +38,6 @@ import org.eclipse.jetty.server.Server;
|
|||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.jetty.http.HttpStatus;
|
|||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -19,7 +19,6 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.bio.SocketConnector;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.SimpleRequest;
|
||||
import org.junit.AfterClass;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.server.session;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ import java.util.EventListener;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -28,7 +30,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.Part;
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.eclipse.jetty.http.HttpCookie;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
package org.eclipse.jetty.server.ssl;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -15,13 +15,10 @@ import javax.net.ssl.SSLEngineResult;
|
|||
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
|
||||
import javax.net.ssl.SSLProtocolException;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
|
|
@ -19,13 +19,10 @@ import java.io.InputStream;
|
|||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.ByteChannel;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileChannel.MapMode;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.swing.text.Position;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/**
|
||||
|
|
|
@ -21,8 +21,6 @@ import java.util.TimeZone;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Date Format Cache.
|
||||
* Computes String representations of Dates and caches
|
||||
|
|
|
@ -29,10 +29,7 @@ import java.io.InputStreamReader;
|
|||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
import javax.servlet.ServletException;
|
||||
|
|
|
@ -14,10 +14,8 @@
|
|||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
|
||||
|
|
|
@ -19,10 +19,8 @@ import java.lang.reflect.Method;
|
|||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.net.ssl.CertPathTrustManagerParameters;
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
|
|
|
@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,11 +17,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
|
|
Loading…
Reference in New Issue