The connection upgrade check is necessary both after the parsing and
after the handling. After the parsing covers HTTP/2 prior knowledge
"PRI * HTTP/2" case; after the handling covers the WebSocket case.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2019-10-02 10:18:06 +02:00
parent bb939f6f71
commit 7810f2dec2
1 changed files with 8 additions and 1 deletions

View File

@ -257,12 +257,19 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
// Parse the request buffer. // Parse the request buffer.
boolean handle = parseRequestBuffer(); boolean handle = parseRequestBuffer();
// There could be a connection upgrade before handling
// the HTTP/1.1 request, for example PRI * HTTP/2.
// If there was a connection upgrade, the other
// connection took over, nothing more to do here.
if (getEndPoint().getConnection() != this)
break;
// Handle channel event // Handle channel event
if (handle) if (handle)
{ {
boolean suspended = !_channel.handle(); boolean suspended = !_channel.handle();
// We should break iteration if we have suspended or changed connection or this is not the handling thread. // We should break iteration if we have suspended or upgraded the connection.
if (suspended || getEndPoint().getConnection() != this) if (suspended || getEndPoint().getConnection() != this)
break; break;
} }