throws IOException { ensureBuffersExist();
Stream(Integer identifier, Http2UpgradeHandler handler, Request coyoteRequest) { super(identifier); this.handler = handler; handler.addChild(this); setWindowSize(handler.getRemoteSettings().getInitialWindowSize()); state = new StreamStateMachine(this); if (coyoteRequest == null) { // HTTP/2 new request this.coyoteRequest = new Request(); this.inputBuffer = new StreamInputBuffer(); this.coyoteRequest.setInputBuffer(inputBuffer); } else { // HTTP/1.1 upgrade this.coyoteRequest = coyoteRequest; this.inputBuffer = null; // Headers have been populated by this point state.receivedStartOfHeaders(); // TODO Assuming the body has been read at this point is not valid state.receivedEndOfStream(); } this.coyoteRequest.setSendfile(handler.hasAsyncIO() && handler.getProtocol().getUseSendfile()); this.coyoteResponse.setOutputBuffer(http2OutputBuffer); this.coyoteRequest.setResponse(coyoteResponse); this.coyoteRequest.protocol().setString("HTTP/2.0"); if (this.coyoteRequest.getStartTime() < 0) { this.coyoteRequest.setStartTime(System.currentTimeMillis()); } }
@Override protected final void registerReadInterest() { stream.getInputBuffer().registerReadInterest(); }
@Override protected final boolean isRequestBodyFullyRead() { return stream.getInputBuffer().isRequestBodyFullyRead(); }
@Override protected final int available(boolean doRead) { return stream.getInputBuffer().available(); }
private final ByteBuffer getInBuffer() { ensureBuffersExist(); return inBuffer; }
@Override public void endRequestBodyFrame(int streamId) throws Http2Exception { Stream stream = getStream(streamId, true); stream.getInputBuffer().onDataAvailable(); }
final void registerReadInterest() { ensureBuffersExist(); synchronized (inBuffer) { readInterest = true; } }
@Override protected final void setRequestBody(ByteChunk body) { stream.getInputBuffer().insertReplayedBody(body); try { stream.receivedEndOfStream(); } catch (ConnectionException e) { // Exception will not be thrown in this case } }