private void writeHuffmanEncodableValue(ByteBuffer target, HttpString headerName, String val) { if (hpackHeaderFunction.shouldUseHuffman(headerName, val)) { if (!HPackHuffman.encode(target, val, false)) { writeValueString(target, val); } } else { writeValueString(target, val); } }
@Override public long transferTo(long position, long count, FileChannel target) throws IOException { long read = super.transferTo(position, count, target); updateFlowControlWindow((int) read); return read; }
public Http2HeadersStreamSinkChannel getResponseChannel() { if (response != null) { return response; } response = new Http2HeadersStreamSinkChannel(getHttp2Channel(), streamId); getHttp2Channel().registerStreamSink(response); return response; }
@Override protected void handleBrokenSourceChannel(Throwable e) { UndertowLogger.REQUEST_LOGGER.debugf(e, "Closing HTTP2 channel to %s due to broken read side", getPeerAddress()); if (e instanceof ConnectionErrorException) { sendGoAway(((ConnectionErrorException) e).getCode(), new Http2ControlMessageExceptionHandler()); } else { sendGoAway(e instanceof ClosedChannelException ? Http2Channel.ERROR_CONNECT_ERROR : Http2Channel.ERROR_PROTOCOL_ERROR, new Http2ControlMessageExceptionHandler()); } }
private void sendSettingsAck() { if(!initialSettingsSent) { sendSettings(); initialSettingsSent = true; } Http2SettingsStreamSinkChannel stream = new Http2SettingsStreamSinkChannel(this); flushChannelIgnoreFailure(stream); }
@Override public long read(ByteBuffer[] dsts, int offset, int length) throws IOException { long read = super.read(dsts, offset, length); updateFlowControlWindow((int) read); return read; }
private void sendPreface() { Http2PrefaceStreamSinkChannel preface = new Http2PrefaceStreamSinkChannel(this); flushChannelIgnoreFailure(preface); } @Override
public void sendUpdateWindowSize(int streamId, int delta) throws IOException { Http2WindowUpdateStreamSinkChannel windowUpdateStreamSinkChannel = new Http2WindowUpdateStreamSinkChannel(this, streamId, delta); flushChannel(windowUpdateStreamSinkChannel); }
@Override public void close() throws IOException { channel.sendRstStream(requestChannel.getStreamId(), Http2Channel.ERROR_CANCEL); }
public void sendGoAway(int status) { sendGoAway(status, new Http2ControlMessageExceptionHandler()); }
Http2PingStreamSourceChannel(Http2Channel framedChannel, byte[] pingData, boolean ack) { super(framedChannel); this.data = pingData; this.ack = ack; lastFrame(); }
@Override public int getPosition() { return super.getPosition() + entryPositionCounter + STATIC_TABLE_LENGTH; } }
@Override protected void moreData(int data) { super.moreData(data); frameRemaining += data; }
Http2RstStreamStreamSourceChannel(Http2Channel framedChannel, PooledByteBuffer data, int errorCode, int streamId) { super(framedChannel, data, 0); this.errorCode = errorCode; this.streamId = streamId; lastFrame(); }
@Override void rstStream(int error) { if (rst) { return; } rst = true; markStreamBroken(); }
Http2PushPromiseStreamSourceChannel(Http2Channel framedChannel, PooledByteBuffer data, long frameDataRemaining, HeaderMap headers, int pushedStreamId, int associatedStreamId) { super(framedChannel, data, frameDataRemaining); this.headers = headers; this.pushedStreamId = pushedStreamId; this.associatedStreamId = associatedStreamId; lastFrame(); }
private void addStaticTableEntry(int index) throws HpackException { //adds an entry from the static table. HeaderField entry = Hpack.STATIC_TABLE[index]; headerEmitter.emitHeader(entry.name, entry.value == null ? "" : entry.value, false); }
Http2DataStreamSinkChannel(Http2Channel channel, int streamId, HeaderMap headers, int frameType) { super(channel, streamId); this.encoder = channel.getEncoder(); this.headers = headers; this.frameType = frameType; }
@Override public int read(ByteBuffer dst) throws IOException { int read = super.read(dst); updateFlowControlWindow(read); return read; }
@Override public long read(ByteBuffer[] dsts) throws IOException { long read = super.read(dsts); updateFlowControlWindow((int) read); return read; }