void reset(long contentLength, HttpServerExchange exchange) { this.exchange = exchange; super.reset(contentLength, !exchange.isPersistent()); }
@Override protected void queueCloseFrames() { processAJPHeader(); final ByteBuffer buffer = exchange.isPersistent() ? CLOSE_FRAME_PERSISTENT.duplicate() : CLOSE_FRAME_NON_PERSISTENT.duplicate(); queueFrame(null, buffer); }
@Override public void terminateReads() throws IOException { if(exchange.isPersistent() && anyAreSet(state, STATE_FINISHED)) { return; } super.terminateReads(); }
@Override protected void doTerminateWrites() throws IOException { try { if (!exchange.isPersistent()) { next.terminateWrites(); } state |= FLAG_WRITE_SHUTDOWN; } catch (IOException | RuntimeException e) { IoUtils.safeClose(exchange.getConnection()); throw e; } }
public void exchangeComplete(final HttpServerExchange exchange) { if (!exchange.isUpgrade() && exchange.isPersistent()) { startRequest(); ConduitStreamSourceChannel channel = ((AjpServerConnection) exchange.getConnection()).getChannel().getSourceChannel(); channel.getReadSetter().set(this); channel.wakeupReads(); } else if(!exchange.isPersistent()) { safeClose(exchange.getConnection()); } }
private static StreamSinkConduit handleResponseConduit(HttpServerExchange exchange, boolean headRequest, StreamSinkConduit channel, HeaderMap responseHeaders, ConduitListener<StreamSinkConduit> finishListener, String transferEncodingHeader) { if (transferEncodingHeader == null) { if (exchange.isHttp11()) { if (exchange.isPersistent()) { responseHeaders.put(Headers.TRANSFER_ENCODING, Headers.CHUNKED.toString()); if (headRequest) { return channel; } return new ChunkedStreamSinkConduit(channel, exchange.getConnection().getByteBufferPool(), true, !exchange.isPersistent(), responseHeaders, finishListener, exchange); } else { if (headRequest) { return channel; } return new FinishableStreamSinkConduit(channel, finishListener); } } else { exchange.setPersistent(false); responseHeaders.put(Headers.CONNECTION, Headers.CLOSE.toString()); if (headRequest) { return channel; } return new FinishableStreamSinkConduit(channel, finishListener); } } else { //moved outside because this is rarely used //and makes the method small enough to be inlined return handleExplicitTransferEncoding(exchange, channel, finishListener, responseHeaders, transferEncodingHeader, headRequest); } }
private static StreamSinkConduit handleExplicitTransferEncoding(HttpServerExchange exchange, StreamSinkConduit channel, ConduitListener<StreamSinkConduit> finishListener, HeaderMap responseHeaders, String transferEncodingHeader, boolean headRequest) { HttpString transferEncoding = new HttpString(transferEncodingHeader); if (transferEncoding.equals(Headers.CHUNKED)) { if (headRequest) { return channel; } Boolean preChunked = exchange.getAttachment(HttpAttachments.PRE_CHUNKED_RESPONSE); if(preChunked != null && preChunked) { return new PreChunkedStreamSinkConduit(channel, finishListener, exchange); } else { return new ChunkedStreamSinkConduit(channel, exchange.getConnection().getByteBufferPool(), true, !exchange.isPersistent(), responseHeaders, finishListener, exchange); } } else { if (headRequest) { return channel; } log.trace("Cancelling persistence because response is identity with no content length"); // make it not persistent - very unfortunate for the next request handler really... exchange.setPersistent(false); responseHeaders.put(Headers.CONNECTION, Headers.CLOSE.toString()); return new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange)); } }
copyHeaders(outboundRequestHeaders, inboundRequestHeaders); if (!exchange.isPersistent()) {
if (!exchange.isPersistent()) { responseHeaders.put(Headers.CONNECTION, Headers.CLOSE.toString()); } else if (exchange.isPersistent() && connection != null) { if (HttpString.tryFromString(connection).equals(Headers.CLOSE)) { exchange.setPersistent(false);
boolean persistent = exchange.isPersistent(); exchange.setPersistent(false); //UNDERTOW-947 MCMP should not use persistent connections if (CONFIG.equals(method)) {
connection.setCurrentExchange(null); final HttpServerConnection connection = this.connection; if (exchange.isPersistent() && !isUpgradeOrConnect(exchange)) { final StreamConnection channel = connection.getChannel(); if (connection.getExtraBytes() == null) { } else if (!exchange.isPersistent()) { ConnectionUtils.cleanClose(connection.getChannel(), connection); } else {
void reset(long contentLength, HttpServerExchange exchange) { this.exchange = exchange; super.reset(contentLength, !exchange.isPersistent()); }
@Override protected void queueCloseFrames() { processAJPHeader(); final ByteBuffer buffer = exchange.isPersistent() ? CLOSE_FRAME_PERSISTENT.duplicate() : CLOSE_FRAME_NON_PERSISTENT.duplicate(); queueFrame(null, buffer); }
@Override protected void queueCloseFrames() { processAJPHeader(); final ByteBuffer buffer = exchange.isPersistent() ? CLOSE_FRAME_PERSISTENT.duplicate() : CLOSE_FRAME_NON_PERSISTENT.duplicate(); queueFrame(null, buffer); }
@Override public void terminateReads() throws IOException { if(exchange.isPersistent() && anyAreSet(state, STATE_FINISHED)) { return; } super.terminateReads(); }
@Override public void terminateReads() throws IOException { if(exchange.isPersistent() && anyAreSet(state, STATE_FINISHED)) { return; } super.terminateReads(); }
@Override protected void doTerminateWrites() throws IOException { try { if (!exchange.isPersistent()) { next.terminateWrites(); } state |= FLAG_WRITE_SHUTDOWN; } catch (IOException | RuntimeException e) { IoUtils.safeClose(exchange.getConnection()); throw e; } }
@Override protected void doTerminateWrites() throws IOException { try { if (!exchange.isPersistent()) { next.terminateWrites(); } state |= FLAG_WRITE_SHUTDOWN; } catch (IOException | RuntimeException e) { IoUtils.safeClose(exchange.getConnection()); throw e; } }
public void exchangeComplete(final HttpServerExchange exchange) { if (!exchange.isUpgrade() && exchange.isPersistent()) { startRequest(); ConduitStreamSourceChannel channel = ((AjpServerConnection) exchange.getConnection()).getChannel().getSourceChannel(); channel.getReadSetter().set(this); channel.wakeupReads(); } else if(!exchange.isPersistent()) { safeClose(exchange.getConnection()); } }
public void exchangeComplete(final HttpServerExchange exchange) { if (!exchange.isUpgrade() && exchange.isPersistent()) { startRequest(); ConduitStreamSourceChannel channel = ((AjpServerConnection) exchange.getConnection()).getChannel().getSourceChannel(); channel.getReadSetter().set(this); channel.wakeupReads(); } else if(!exchange.isPersistent()) { safeClose(exchange.getConnection()); } }