Fixes #3311 - Ability to serve HTTP and HTTPS from the same port.
Fixed handling of upgradeTo() in case of null buffers. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
ccda1ee5f6
commit
5061a5ca30
|
@ -427,15 +427,16 @@ public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("{} upgrading from {} to {}", this, old_connection, newConnection);
|
LOG.debug("{} upgrading from {} to {}", this, old_connection, newConnection);
|
||||||
|
|
||||||
ByteBuffer prefilled = (old_connection instanceof Connection.UpgradeFrom)
|
ByteBuffer buffer = (old_connection instanceof Connection.UpgradeFrom) ?
|
||||||
?((Connection.UpgradeFrom)old_connection).onUpgradeFrom():null;
|
((Connection.UpgradeFrom)old_connection).onUpgradeFrom() :
|
||||||
|
null;
|
||||||
old_connection.onClose();
|
old_connection.onClose();
|
||||||
old_connection.getEndPoint().setConnection(newConnection);
|
old_connection.getEndPoint().setConnection(newConnection);
|
||||||
|
|
||||||
if (newConnection instanceof Connection.UpgradeTo)
|
if (newConnection instanceof Connection.UpgradeTo)
|
||||||
((Connection.UpgradeTo)newConnection).onUpgradeTo(prefilled);
|
((Connection.UpgradeTo)newConnection).onUpgradeTo(buffer);
|
||||||
else if (BufferUtil.hasContent(prefilled))
|
else if (BufferUtil.hasContent(buffer))
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException("Cannot upgrade: " + newConnection + " does not implement " + Connection.UpgradeTo.class.getName());
|
||||||
|
|
||||||
newConnection.onOpen();
|
newConnection.onOpen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,8 +269,11 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr
|
||||||
@Override
|
@Override
|
||||||
public void onUpgradeTo(ByteBuffer buffer)
|
public void onUpgradeTo(ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
acquireEncryptedInput();
|
if (BufferUtil.hasContent(buffer))
|
||||||
BufferUtil.append(_encryptedInput, buffer);
|
{
|
||||||
|
acquireEncryptedInput();
|
||||||
|
BufferUtil.append(_encryptedInput, buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -199,7 +199,8 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
||||||
@Override
|
@Override
|
||||||
public void onUpgradeTo(ByteBuffer buffer)
|
public void onUpgradeTo(ByteBuffer buffer)
|
||||||
{
|
{
|
||||||
BufferUtil.append(getRequestBuffer(), buffer);
|
if (BufferUtil.hasContent(buffer))
|
||||||
|
BufferUtil.append(getRequestBuffer(), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue