PR # 12186 - changes from review

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
This commit is contained in:
Lachlan Roberts 2024-09-02 15:52:53 +10:00
parent 9fbde9b71e
commit f795fb10d0
No known key found for this signature in database
GPG Key ID: 5663FB7A8FF7E348
7 changed files with 18 additions and 20 deletions

View File

@ -455,7 +455,7 @@ public class HttpGenerator
}
}
public void upgrade()
public void startTunnel()
{
_noContentResponse = false;
_state = State.COMMITTED;
@ -464,7 +464,7 @@ public class HttpGenerator
@Deprecated(since = "12.1.0", forRemoval = true)
public void servletUpgrade()
{
upgrade();
startTunnel();
}
private void prepareChunk(ByteBuffer chunk, int remaining)

View File

@ -2016,7 +2016,7 @@ public class HttpParser
_headerComplete = false;
}
public void upgrade()
public void startTunnel()
{
setState(State.EOF_CONTENT);
_endOfContent = EndOfContent.EOF_CONTENT;
@ -2026,7 +2026,7 @@ public class HttpParser
@Deprecated(since = "12.1.0", forRemoval = true)
public void servletUpgrade()
{
upgrade();
startTunnel();
}
protected void setState(State state)

View File

@ -141,15 +141,13 @@ public interface Connection extends Closeable
}
/**
* <p>{@link Connection} implementations implement this interface when they
* can be upgraded to a different protocol. For an HTTP request it will read
* content from the request until EOF treating this as bytes over the new
* protocol.</p>
* <p>This is used for the {@code HttpServletRequest#upgrade()} implementation.</p>
* <p>Start a tunnel over the current connection without replacing the connection.</p>
* <p>This can be used for upgrade within a connection, but it is not really an upgrade for this connection
* as the connection remains and just tunnels data to/from its endpoint.</p>
*/
interface Upgrade
interface Tunnel
{
void upgrade();
void startTunnel();
}
/**

View File

@ -80,7 +80,7 @@ import static org.eclipse.jetty.http.HttpStatus.INTERNAL_SERVER_ERROR_500;
/**
* <p>A {@link Connection} that handles the HTTP protocol.</p>
*/
public class HttpConnection extends AbstractMetaDataConnection implements Runnable, Connection.UpgradeFrom, Connection.UpgradeTo, Connection.Upgrade, ConnectionMetaData
public class HttpConnection extends AbstractMetaDataConnection implements Runnable, Connection.UpgradeFrom, Connection.UpgradeTo, Connection.Tunnel, ConnectionMetaData
{
private static final Logger LOG = LoggerFactory.getLogger(HttpConnection.class);
private static final HttpField PREAMBLE_UPGRADE_H2C = new HttpField(HttpHeader.UPGRADE, "h2c");
@ -336,10 +336,10 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
}
@Override
public void upgrade()
public void startTunnel()
{
getParser().upgrade();
getGenerator().upgrade();
getParser().startTunnel();
getGenerator().startTunnel();
}
void releaseRequestBuffer()

View File

@ -952,10 +952,10 @@ public class ServletApiRequest implements HttpServletRequest
}
Connection connection = _servletContextRequest.getConnectionMetaData().getConnection();
if (connection instanceof Connection.Upgrade upgradeableConnection)
if (connection instanceof Connection.Tunnel upgradeableConnection)
{
outputStream.flush(); // commit the 101 response
upgradeableConnection.upgrade();
upgradeableConnection.startTunnel();
}
else
{

View File

@ -952,10 +952,10 @@ public class ServletApiRequest implements HttpServletRequest
}
Connection connection = _servletContextRequest.getConnectionMetaData().getConnection();
if (connection instanceof Connection.Upgrade upgradeableConnection)
if (connection instanceof Connection.Tunnel upgradeableConnection)
{
outputStream.flush(); // commit the 101 response
upgradeableConnection.upgrade();
upgradeableConnection.startTunnel();
}
else
{

View File

@ -596,7 +596,7 @@ public class Request implements HttpServletRequest
* <dl>
* <dt>org.eclipse.jetty.server.Server</dt><dd>The Jetty Server instance</dd>
* <dt>org.eclipse.jetty.server.HttpChannel</dt><dd>The HttpChannel for this request</dd>
* <dt>org.eclipse.jetty.server.internal.HttpConnection</dt><dd>The HttpConnection or null if another transport is used</dd>
* <dt>org.eclipse.jetty.io.Connection</dt><dd>The Connection or null if another transport is used</dd>
* </dl>
* While these attributes may look like security problems, they are exposing nothing that is not already
* available via reflection from a Request instance.