WIP updates from review
This commit is contained in:
parent
d4dcd6a8c8
commit
9eb9e7d38e
|
@ -363,8 +363,8 @@ public class HttpChannelState implements HttpChannel, Components
|
|||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("onIdleTimeout {}", this, t);
|
||||
|
||||
// Too late?
|
||||
if (_request == null || _response == null)
|
||||
// too late?
|
||||
if (_stream == null)
|
||||
return null;
|
||||
|
||||
Runnable invokeOnContentAvailable = null;
|
||||
|
@ -445,7 +445,8 @@ public class HttpChannelState implements HttpChannel, Components
|
|||
// If not handled, then we just fail the request callback
|
||||
if (!_handled && _handling == null)
|
||||
{
|
||||
task = () -> _request._callback.failed(x);
|
||||
Callback callback = _request._callback;
|
||||
task = () -> callback.failed(x);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -583,10 +583,16 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
|||
return true;
|
||||
|
||||
Runnable task;
|
||||
if (_delayedForContent && _onRequest != null)
|
||||
|
||||
if (_delayedForContent || _onRequest == null)
|
||||
{
|
||||
task = _httpChannel.onIdleTimeout(timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
Runnable onRequest = _onRequest;
|
||||
_onRequest = null;
|
||||
|
||||
task = () ->
|
||||
{
|
||||
try
|
||||
|
@ -596,19 +602,12 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
|||
finally
|
||||
{
|
||||
_handling.set(false);
|
||||
Runnable next = _httpChannel.onIdleTimeout(timeout);
|
||||
if (next != null)
|
||||
getExecutor().execute(next);
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
task = _httpChannel.onIdleTimeout(timeout);
|
||||
}
|
||||
if (task != null)
|
||||
getExecutor().execute(task);
|
||||
return false; // We've handle the exception
|
||||
return false; // We've handle (or ignored) the timeout
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -967,11 +966,16 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
|||
_onRequest = stream.headerComplete();
|
||||
|
||||
// Should we delay dispatch until we have some content?
|
||||
_delayedForContent = getHttpConfiguration().isDelayDispatchUntilContent() &&
|
||||
if (getHttpConfiguration().isDelayDispatchUntilContent() &&
|
||||
getEndPoint().getIdleTimeout() > 0 &&
|
||||
(_parser.getContentLength() > 0 || _parser.isChunking()) &&
|
||||
!stream._expects100Continue &&
|
||||
!stream.isCommitted() &&
|
||||
_requestBuffer != null && _requestBuffer.isEmpty();
|
||||
_requestBuffer != null && _requestBuffer.isEmpty())
|
||||
{
|
||||
getEndPoint().setIdleTimeout(getEndPoint().getIdleTimeout() / 2);
|
||||
_delayedForContent = true;
|
||||
}
|
||||
|
||||
return !_delayedForContent;
|
||||
}
|
||||
|
@ -988,7 +992,11 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab
|
|||
|
||||
_requestBuffer.retain();
|
||||
stream._chunk = Content.Chunk.asChunk(buffer, false, _requestBuffer);
|
||||
if (_delayedForContent)
|
||||
{
|
||||
_delayedForContent = false;
|
||||
getEndPoint().setIdleTimeout(getEndPoint().getIdleTimeout() * 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
|
@ -139,7 +138,6 @@ public class ServletTest
|
|||
}, "/post");
|
||||
|
||||
_connector.setIdleTimeout(idleTimeout);
|
||||
_connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchUntilContent(false);
|
||||
_server.start();
|
||||
|
||||
try (LocalConnector.LocalEndPoint endPoint = _connector.connect())
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
|
@ -142,7 +141,6 @@ public class ServletTest
|
|||
}, "/post");
|
||||
|
||||
_connector.setIdleTimeout(idleTimeout);
|
||||
_connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchUntilContent(false);
|
||||
_server.start();
|
||||
|
||||
try (LocalConnector.LocalEndPoint endPoint = _connector.connect())
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpTester;
|
||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
|
@ -134,7 +133,6 @@ public class ServletTest
|
|||
}), "/post");
|
||||
|
||||
_connector.setIdleTimeout(idleTimeout);
|
||||
_connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchUntilContent(false);
|
||||
_server.start();
|
||||
|
||||
try (LocalConnector.LocalEndPoint endPoint = _connector.connect())
|
||||
|
|
Loading…
Reference in New Issue