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())
|
||||
LOG.debug("{} upgrading from {} to {}", this, old_connection, newConnection);
|
||||
|
||||
ByteBuffer prefilled = (old_connection instanceof Connection.UpgradeFrom)
|
||||
?((Connection.UpgradeFrom)old_connection).onUpgradeFrom():null;
|
||||
ByteBuffer buffer = (old_connection instanceof Connection.UpgradeFrom) ?
|
||||
((Connection.UpgradeFrom)old_connection).onUpgradeFrom() :
|
||||
null;
|
||||
old_connection.onClose();
|
||||
old_connection.getEndPoint().setConnection(newConnection);
|
||||
|
||||
if (newConnection instanceof Connection.UpgradeTo)
|
||||
((Connection.UpgradeTo)newConnection).onUpgradeTo(prefilled);
|
||||
else if (BufferUtil.hasContent(prefilled))
|
||||
throw new IllegalStateException();
|
||||
((Connection.UpgradeTo)newConnection).onUpgradeTo(buffer);
|
||||
else if (BufferUtil.hasContent(buffer))
|
||||
throw new IllegalStateException("Cannot upgrade: " + newConnection + " does not implement " + Connection.UpgradeTo.class.getName());
|
||||
|
||||
newConnection.onOpen();
|
||||
}
|
||||
|
|
|
@ -269,8 +269,11 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr
|
|||
@Override
|
||||
public void onUpgradeTo(ByteBuffer buffer)
|
||||
{
|
||||
acquireEncryptedInput();
|
||||
BufferUtil.append(_encryptedInput, buffer);
|
||||
if (BufferUtil.hasContent(buffer))
|
||||
{
|
||||
acquireEncryptedInput();
|
||||
BufferUtil.append(_encryptedInput, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -199,7 +199,8 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
@Override
|
||||
public void onUpgradeTo(ByteBuffer buffer)
|
||||
{
|
||||
BufferUtil.append(getRequestBuffer(), buffer);
|
||||
if (BufferUtil.hasContent(buffer))
|
||||
BufferUtil.append(getRequestBuffer(), buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue