@Override protected void exchangeComplete(HttpServerExchange exchange) { if(fixedLengthStreamSinkConduit != null) { fixedLengthStreamSinkConduit.clearExchange(); } if (pipelineBuffer == null) { readListener.exchangeComplete(exchange); } else { pipelineBuffer.exchangeComplete(exchange); } }
public void setPipelineBuffer(PipeliningBufferingStreamSinkConduit pipelineBuffer) { this.pipelineBuffer = pipelineBuffer; this.responseConduit = new HttpResponseConduit(pipelineBuffer, bufferPool, this); this.fixedLengthStreamSinkConduit = new ServerFixedLengthStreamSinkConduit(responseConduit, false, false); }
@Override public void exchangeEvent(HttpServerExchange exchange, NextListener nextListener) { restoreChannel(state); } });
public void exchangeComplete(final HttpServerExchange exchange) { //if we ever fail to read then we flush the pipeline buffer //this relies on us always doing an eager read when starting a request, //rather than waiting to be notified of data being available final HttpServerConnection connection = (HttpServerConnection) exchange.getConnection(); if (connection.getExtraBytes() == null || exchange.isUpgrade()) { performFlush(exchange, connection); } else { connection.getReadListener().exchangeComplete(exchange); } }
@Override public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) { ServerFixedLengthStreamSinkConduit fixed = new ServerFixedLengthStreamSinkConduit(new HttpResponseConduit(getSinkChannel().getConduit(), getByteBufferPool(), HttpServerConnection.this, exchange), false, false); fixed.reset(0, exchange); return fixed; } });
private static StreamSinkConduit handleFixedLength(HttpServerExchange exchange, boolean headRequest, StreamSinkConduit channel, HeaderMap responseHeaders, String contentLengthHeader, HttpServerConnection connection) { try { final long contentLength = parsePositiveLong(contentLengthHeader); if (headRequest) { return channel; } // fixed-length response ServerFixedLengthStreamSinkConduit fixed = connection.getFixedLengthStreamSinkConduit(); fixed.reset(contentLength, exchange); return fixed; } catch (NumberFormatException e) { //we just fix it for them responseHeaders.remove(Headers.CONTENT_LENGTH); } return null; }
private static void processByteVector16(ByteBuffer input) { int int16 = getInt16(input); processByteVector(input, int16); }
private static void processByteVector8(ByteBuffer input) { int int8 = getInt8(input); processByteVector(input, int8); }
public void newRequest() { state.reset(); read = 0; if(parseTimeoutUpdater != null) { parseTimeoutUpdater.connectionIdle(); } connection.setCurrentExchange(null); }
@Override public void run() { handleEvent(connection.getChannel().getSourceChannel()); }
@Override public void handleEvent(ConduitStreamSinkChannel conduitStreamSinkChannel) { connection.getUpgradeListener().handleUpgrade(connection.getChannel(), exchange); } }, new ClosingChannelExceptionHandler<ConduitStreamSinkChannel>(connection)));
/** * removeEldestEntry() should be overridden by the user, otherwise it will not * remove the oldest object from the Map. */ @Override protected boolean removeEldestEntry(Map.Entry<K, V> eldest) { return size() > this.capacity; } }
ParseState(int cacheSize) { this.parseState = 0; this.pos = 0; if(cacheSize <= 0) { headerValuesCache = null; } else { headerValuesCache = new CacheMap<>(cacheSize); } }
@Override public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts) throws SSLException { return unwrap(src, dsts, 0, dsts.length); }
@Override public void handleEvent(StreamConnection channel) { handleEvent(channel, null); }
@Override public SSLEngineResult wrap(ByteBuffer[] srcs, ByteBuffer dst) throws SSLException { return wrap(srcs, 0, srcs.length, dst); }
void clearExchange(){ channelFinished(); }
public long write(final ByteBuffer[] srcs) throws IOException { return write(srcs, 0, srcs.length); }
@Override public void pushBack(PooledByteBuffer pooled) { ((HttpServerConnection) exchange.getConnection()).ungetRequestBytes(pooled); } }, finishListener, exchange, exchange, exchange.getConnection());
private static List<Integer> exploreExtensions(ByteBuffer input, List<Integer> ciphers) throws SSLException { int length = getInt16(input); // length of extensions while (length > 0) { int extType = getInt16(input); // extenson type int extLen = getInt16(input); // length of extension data if (extType == 16) { // 0x00: ty return ciphers; } else { // ignore other extensions processByteVector(input, extLen); } length -= extLen + 4; } return null; }