private HpackEncoder.State encodeContinuationFrame(HeaderMap headers, PooledByteBuffer current) { ByteBuffer currentBuffer; HpackEncoder.State result;//continuation frame //note that if the buffers are small we may not actually need a continuation here //but it greatly reduces the code complexity //back fill the length currentBuffer = current.getBuffer(); currentBuffer.put((byte) 0); currentBuffer.put((byte) 0); currentBuffer.put((byte) 0); currentBuffer.put((byte) Http2Channel.FRAME_TYPE_CONTINUATION); //type currentBuffer.put((byte) 0); //back fill the flags Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); result = encoder.encode(headers, currentBuffer); int contFrameLength = currentBuffer.position() - 9; currentBuffer.put(0, (byte) ((contFrameLength >> 16) & 0xFF)); currentBuffer.put(1, (byte) ((contFrameLength >> 8) & 0xFF)); currentBuffer.put(2, (byte) (contFrameLength & 0xFF)); currentBuffer.put(4, (byte) (result == HpackEncoder.State.COMPLETE ? Http2Channel.HEADERS_FLAG_END_HEADERS : 0 )); //flags return result; }
@Override public void exchangeEvent(HttpServerExchange exchange, NextListener nextListener) { try { channel.sendRstStream(responseChannel.getStreamId(), Http2Channel.ERROR_CANCEL); } finally { nextListener.proceed(); } } });
firstBuffer.put((byte) 0); //back fill the flags Http2ProtocolUtils.putInt(firstBuffer, getStreamId()); Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); if(dataPaddingBytes > 0) { currentBuffer.put((byte) (dataPaddingBytes & 0xFF)); currentBuffer.put((byte) ((dataPaddingBytes > 0 ? Http2Channel.DATA_FLAG_PADDED : 0))); //flags Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); if (dataPaddingBytes > 0) { currentBuffer.put((byte) (dataPaddingBytes & 0xFF)); firstTrailerBuffer.getBuffer().put((byte) (Http2Channel.HEADERS_FLAG_END_STREAM | Http2Channel.HEADERS_FLAG_END_HEADERS)); //back fill the flags Http2ProtocolUtils.putInt(firstTrailerBuffer.getBuffer(), getStreamId()); HpackEncoder.State result = encoder.encode(trailers, firstTrailerBuffer.getBuffer()); if (result != HpackEncoder.State.COMPLETE) {
requestHeaders.put(Http2ReceiveListener.SCHEME, exchange.getRequestScheme()); Http2HeadersStreamSinkChannel sink = channel.sendPushPromise(responseChannel.getStreamId(), requestHeaders, responseHeaders); Http2ServerConnection newConnection = new Http2ServerConnection(channel, sink, getUndertowOptions(), getBufferSize(), rootHandler); final HttpServerExchange exchange = new HttpServerExchange(newConnection, requestHeaders, responseHeaders, getUndertowOptions().get(UndertowOptions.MAX_ENTITY_SIZE, UndertowOptions.DEFAULT_MAX_ENTITY_SIZE));
private HpackEncoder.State encodeContinuationFrame(HeaderMap headers, PooledByteBuffer current) { ByteBuffer currentBuffer; HpackEncoder.State result;//continuation frame //note that if the buffers are small we may not actually need a continuation here //but it greatly reduces the code complexity //back fill the length currentBuffer = current.getBuffer(); currentBuffer.put((byte) 0); currentBuffer.put((byte) 0); currentBuffer.put((byte) 0); currentBuffer.put((byte) Http2Channel.FRAME_TYPE_CONTINUATION); //type currentBuffer.put((byte) 0); //back fill the flags Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); result = encoder.encode(headers, currentBuffer); int contFrameLength = currentBuffer.position() - 9; currentBuffer.put(0, (byte) ((contFrameLength >> 16) & 0xFF)); currentBuffer.put(1, (byte) ((contFrameLength >> 8) & 0xFF)); currentBuffer.put(2, (byte) (contFrameLength & 0xFF)); currentBuffer.put(4, (byte) (result == HpackEncoder.State.COMPLETE ? Http2Channel.HEADERS_FLAG_END_HEADERS : 0 )); //flags return result; }
private HpackEncoder.State encodeContinuationFrame(HeaderMap headers, PooledByteBuffer current) { ByteBuffer currentBuffer; HpackEncoder.State result;//continuation frame //note that if the buffers are small we may not actually need a continuation here //but it greatly reduces the code complexity //back fill the length currentBuffer = current.getBuffer(); currentBuffer.put((byte) 0); currentBuffer.put((byte) 0); currentBuffer.put((byte) 0); currentBuffer.put((byte) Http2Channel.FRAME_TYPE_CONTINUATION); //type currentBuffer.put((byte) 0); //back fill the flags Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); result = encoder.encode(headers, currentBuffer); int contFrameLength = currentBuffer.position() - 9; currentBuffer.put(0, (byte) ((contFrameLength >> 16) & 0xFF)); currentBuffer.put(1, (byte) ((contFrameLength >> 8) & 0xFF)); currentBuffer.put(2, (byte) (contFrameLength & 0xFF)); currentBuffer.put(4, (byte) (result == HpackEncoder.State.COMPLETE ? Http2Channel.HEADERS_FLAG_END_HEADERS : 0 )); //flags return result; }
@Override public void exchangeEvent(HttpServerExchange exchange, NextListener nextListener) { try { channel.sendRstStream(responseChannel.getStreamId(), Http2Channel.ERROR_CANCEL); } finally { nextListener.proceed(); } } });
@Override public void exchangeEvent(HttpServerExchange exchange, NextListener nextListener) { try { channel.sendRstStream(responseChannel.getStreamId(), Http2Channel.ERROR_CANCEL); } finally { nextListener.proceed(); } } });
firstBuffer.put((byte) 0); //back fill the flags Http2ProtocolUtils.putInt(firstBuffer, getStreamId()); Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); if(dataPaddingBytes > 0) { currentBuffer.put((byte) (dataPaddingBytes & 0xFF)); currentBuffer.put((byte) ((dataPaddingBytes > 0 ? Http2Channel.DATA_FLAG_PADDED : 0))); //flags Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); if (dataPaddingBytes > 0) { currentBuffer.put((byte) (dataPaddingBytes & 0xFF)); firstTrailerBuffer.getBuffer().put((byte) (Http2Channel.HEADERS_FLAG_END_STREAM | Http2Channel.HEADERS_FLAG_END_HEADERS)); //back fill the flags Http2ProtocolUtils.putInt(firstTrailerBuffer.getBuffer(), getStreamId()); HpackEncoder.State result = encoder.encode(trailers, firstTrailerBuffer.getBuffer()); if (result != HpackEncoder.State.COMPLETE) {
firstBuffer.put((byte) 0); //back fill the flags Http2ProtocolUtils.putInt(firstBuffer, getStreamId()); Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); if(dataPaddingBytes > 0) { currentBuffer.put((byte) (dataPaddingBytes & 0xFF)); currentBuffer.put((byte) ((dataPaddingBytes > 0 ? Http2Channel.DATA_FLAG_PADDED : 0))); //flags Http2ProtocolUtils.putInt(currentBuffer, getStreamId()); if (dataPaddingBytes > 0) { currentBuffer.put((byte) (dataPaddingBytes & 0xFF)); firstTrailerBuffer.getBuffer().put((byte) (Http2Channel.HEADERS_FLAG_END_STREAM | Http2Channel.HEADERS_FLAG_END_HEADERS)); //back fill the flags Http2ProtocolUtils.putInt(firstTrailerBuffer.getBuffer(), getStreamId()); HpackEncoder.State result = encoder.encode(trailers, firstTrailerBuffer.getBuffer()); if (result != HpackEncoder.State.COMPLETE) {
requestHeaders.put(Http2ReceiveListener.SCHEME, exchange.getRequestScheme()); Http2HeadersStreamSinkChannel sink = channel.sendPushPromise(responseChannel.getStreamId(), requestHeaders, responseHeaders); Http2ServerConnection newConnection = new Http2ServerConnection(channel, sink, getUndertowOptions(), getBufferSize(), rootHandler); final HttpServerExchange exchange = new HttpServerExchange(newConnection, requestHeaders, responseHeaders, getUndertowOptions().get(UndertowOptions.MAX_ENTITY_SIZE, UndertowOptions.DEFAULT_MAX_ENTITY_SIZE));
requestHeaders.put(Http2ReceiveListener.SCHEME, exchange.getRequestScheme()); Http2HeadersStreamSinkChannel sink = channel.sendPushPromise(responseChannel.getStreamId(), requestHeaders, responseHeaders); Http2ServerConnection newConnection = new Http2ServerConnection(channel, sink, getUndertowOptions(), getBufferSize(), rootHandler); final HttpServerExchange exchange = new HttpServerExchange(newConnection, requestHeaders, responseHeaders, getUndertowOptions().get(UndertowOptions.MAX_ENTITY_SIZE, UndertowOptions.DEFAULT_MAX_ENTITY_SIZE));