452188 Delay dispatch until content optimisation.
Renamed property "delayDispatchUntilContent".
This commit is contained in:
parent
1915e592b5
commit
8330fa73e0
|
@ -30,7 +30,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -104,7 +103,7 @@ public class ProxyServletFailureTest
|
|||
proxy = new Server(executor);
|
||||
proxyConnector = new ServerConnector(proxy);
|
||||
proxy.addConnector(proxyConnector);
|
||||
proxyConnector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchOnContent(false);
|
||||
proxyConnector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchUntilContent(false);
|
||||
|
||||
ServletContextHandler proxyCtx = new ServletContextHandler(proxy, "/", true, false);
|
||||
ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<Set name="sendServerVersion"><Property name="jetty.send.server.version" default="true" /></Set>
|
||||
<Set name="sendDateHeader"><Property name="jetty.send.date.header" default="false" /></Set>
|
||||
<Set name="headerCacheSize">512</Set>
|
||||
<Set name="delayDispatchOnContent"><Property name="jetty.delayDispatchOnContent" default="false"/></Set>
|
||||
<Set name="delayDispatchUntilContent"><Property name="jetty.delayDispatchUntilContent" default="false"/></Set>
|
||||
<!-- Uncomment to enable handling of X-Forwarded- style headers
|
||||
<Call name="addCustomizer">
|
||||
<Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
|
||||
|
|
|
@ -46,4 +46,4 @@ jetty.dump.start=false
|
|||
# Dump the state of the Jetty server, before stop
|
||||
jetty.dump.stop=false
|
||||
# Enable delayed dispatch optimisation
|
||||
jetty.delayDispatchOnContent=false
|
||||
jetty.delayDispatchUntilContent=false
|
||||
|
|
|
@ -50,12 +50,11 @@ public class HttpConfiguration
|
|||
private int _headerCacheSize=512;
|
||||
private int _securePort;
|
||||
private String _secureScheme = HttpScheme.HTTPS.asString();
|
||||
private boolean _sendServerVersion = true; //send Server: header
|
||||
private boolean _sendXPoweredBy = false; //send X-Powered-By: header
|
||||
private boolean _sendDateHeader = true; //send Date: header
|
||||
private boolean _delayDispatchOnContent = false; // Don't dispatch until content arrives
|
||||
private boolean _sendServerVersion = true;
|
||||
private boolean _sendXPoweredBy = false;
|
||||
private boolean _sendDateHeader = true;
|
||||
private boolean _delayDispatchUntilContent = false;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* <p>An interface that allows a request object to be customized
|
||||
|
@ -211,24 +210,23 @@ public class HttpConfiguration
|
|||
{
|
||||
return _sendDateHeader;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param delay if true, delay the application dispatch until content is available
|
||||
*/
|
||||
public void setDelayDispatchOnContent(boolean delay)
|
||||
public void setDelayDispatchUntilContent(boolean delay)
|
||||
{
|
||||
_delayDispatchOnContent=delay;
|
||||
_delayDispatchUntilContent = delay;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@ManagedAttribute("if true, delay the application dispatch until content is available")
|
||||
public boolean isDelayDispatchOnContent()
|
||||
public boolean isDelayDispatchUntilContent()
|
||||
{
|
||||
return _delayDispatchOnContent;
|
||||
return _delayDispatchUntilContent;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* <p>Set the {@link Customizer}s that are invoked for every
|
||||
|
|
|
@ -528,14 +528,16 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
if (!persistent)
|
||||
_generator.setPersistent(false);
|
||||
|
||||
boolean superhc = super.headerComplete();
|
||||
if (!super.headerComplete())
|
||||
return false;
|
||||
|
||||
// Should we delay dispatch until we have some content?
|
||||
// We should not delay if there is no content expect or client is expecting 100 or the response is already committed or the request buffer already has something in it to parse
|
||||
if (superhc && getHttpConfiguration().isDelayDispatchOnContent() && _parser.getContentLength()>0 && !isExpecting100Continue() && !isCommitted() && BufferUtil.isEmpty(_requestBuffer))
|
||||
if (getHttpConfiguration().isDelayDispatchUntilContent() && _parser.getContentLength() > 0 &&
|
||||
!isExpecting100Continue() && !isCommitted() && BufferUtil.isEmpty(_requestBuffer))
|
||||
return false;
|
||||
|
||||
return superhc;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,16 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -41,7 +31,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.Arrays;
|
||||
import java.util.concurrent.Exchanger;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
@ -59,6 +48,16 @@ import org.hamcrest.Matchers;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -1278,7 +1277,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
|||
{
|
||||
AvailableHandler ah = new AvailableHandler();
|
||||
configureServer(ah);
|
||||
_connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchOnContent(false);
|
||||
_connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setDelayDispatchUntilContent(false);
|
||||
|
||||
try (Socket client = newSocket(_serverURI.getHost(), _serverURI.getPort()))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue