Issue #1671 asymmetric trailer usage on MetaData.Request
This commit is contained in:
parent
f80ff4f544
commit
6b095d823d
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.servlet.DispatcherType;
|
import javax.servlet.DispatcherType;
|
||||||
import javax.servlet.RequestDispatcher;
|
import javax.servlet.RequestDispatcher;
|
||||||
|
@ -75,9 +76,18 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
||||||
private final HttpChannelState _state;
|
private final HttpChannelState _state;
|
||||||
private final Request _request;
|
private final Request _request;
|
||||||
private final Response _response;
|
private final Response _response;
|
||||||
|
private final Supplier<HttpFields> _trailerSupplier = new Supplier<HttpFields>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public HttpFields get()
|
||||||
|
{
|
||||||
|
return _trailers;
|
||||||
|
}
|
||||||
|
};
|
||||||
private MetaData.Response _committedMetaData;
|
private MetaData.Response _committedMetaData;
|
||||||
private RequestLog _requestLog;
|
private RequestLog _requestLog;
|
||||||
private long _oldIdleTimeout;
|
private long _oldIdleTimeout;
|
||||||
|
private HttpFields _trailers;
|
||||||
|
|
||||||
/** Bytes written after interception (eg after compression) */
|
/** Bytes written after interception (eg after compression) */
|
||||||
private long _written;
|
private long _written;
|
||||||
|
@ -581,6 +591,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
||||||
if (idleTO>=0 && _oldIdleTimeout!=idleTO)
|
if (idleTO>=0 && _oldIdleTimeout!=idleTO)
|
||||||
setIdleTimeout(idleTO);
|
setIdleTimeout(idleTO);
|
||||||
|
|
||||||
|
request.setTrailerSupplier(_trailerSupplier);
|
||||||
_request.setMetaData(request);
|
_request.setMetaData(request);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
|
@ -608,7 +619,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("{} onTrailers {}", this, trailers);
|
LOG.debug("{} onTrailers {}", this, trailers);
|
||||||
_request.setTrailers(trailers);
|
_trailers = trailers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onRequestComplete()
|
public boolean onRequestComplete()
|
||||||
|
|
|
@ -39,6 +39,7 @@ import java.util.EventListener;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.servlet.AsyncContext;
|
import javax.servlet.AsyncContext;
|
||||||
|
@ -199,7 +200,6 @@ public class Request implements HttpServletRequest
|
||||||
private long _timeStamp;
|
private long _timeStamp;
|
||||||
private MultiPartInputStreamParser _multiPartInputStream; //if the request is a multi-part mime
|
private MultiPartInputStreamParser _multiPartInputStream; //if the request is a multi-part mime
|
||||||
private AsyncContextState _async;
|
private AsyncContextState _async;
|
||||||
private HttpFields _trailers;
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public Request(HttpChannel channel, HttpInput input)
|
public Request(HttpChannel channel, HttpInput input)
|
||||||
|
@ -215,9 +215,12 @@ public class Request implements HttpServletRequest
|
||||||
return metadata==null?null:metadata.getFields();
|
return metadata==null?null:metadata.getFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
public HttpFields getTrailers()
|
public HttpFields getTrailers()
|
||||||
{
|
{
|
||||||
return _trailers;
|
MetaData.Request metadata=_metaData;
|
||||||
|
Supplier<HttpFields> trailers = metadata==null?null:metadata.getTrailerSupplier();
|
||||||
|
return trailers==null?null:trailers.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -1859,7 +1862,6 @@ public class Request implements HttpServletRequest
|
||||||
_multiPartInputStream = null;
|
_multiPartInputStream = null;
|
||||||
_remote=null;
|
_remote=null;
|
||||||
_input.recycle();
|
_input.recycle();
|
||||||
_trailers = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -2228,11 +2230,6 @@ public class Request implements HttpServletRequest
|
||||||
_scope = scope;
|
_scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTrailers(HttpFields trailers)
|
|
||||||
{
|
|
||||||
_trailers = trailers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public AsyncContext startAsync() throws IllegalStateException
|
public AsyncContext startAsync() throws IllegalStateException
|
||||||
|
|
Loading…
Reference in New Issue