Search in sources :

Example 26 with GoAwayFrame

use of com.webpieces.http2parser.api.dto.GoAwayFrame in project webpieces by deanhiller.

the class GoAwayMarshaller method marshal.

@Override
public DataWrapper marshal(Http2Frame frame) {
    if (frame.getStreamId() != 0)
        throw new IllegalArgumentException("GoAwayFrame can never be any other stream id except 0 which is already set");
    GoAwayFrame castFrame = (GoAwayFrame) frame;
    long originalStreamId = castFrame.getLastStreamId();
    long streamId = originalStreamId & 0x7FFFFFFF;
    if (streamId != originalStreamId)
        throw new RuntimeException("your lastStreamId is too large per spec. frame=" + frame);
    ByteBuffer prelude = bufferPool.nextBuffer(8);
    UnsignedData.putUnsignedInt(prelude, castFrame.getLastStreamId());
    UnsignedData.putUnsignedInt(prelude, castFrame.getErrorCode());
    prelude.flip();
    DataWrapper debug = dataGen.emptyWrapper();
    if (castFrame.getDebugData() != null)
        debug = castFrame.getDebugData();
    DataWrapper payload = dataGen.chainDataWrappers(dataGen.wrapByteBuffer(prelude), debug);
    return super.marshalFrame(frame, (byte) 0, payload);
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) ByteBuffer(java.nio.ByteBuffer) GoAwayFrame(com.webpieces.http2parser.api.dto.GoAwayFrame)

Aggregations

GoAwayFrame (com.webpieces.http2parser.api.dto.GoAwayFrame)26 Test (org.junit.Test)23 DataWrapper (org.webpieces.data.api.DataWrapper)17 Http2Request (com.webpieces.hpack.api.dto.Http2Request)10 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)8 MockResponseListener (org.webpieces.http2client.mock.MockResponseListener)7 ConnectionClosedException (com.webpieces.http2engine.api.ConnectionClosedException)5 StreamWriter (com.webpieces.http2engine.api.StreamWriter)5 ShutdownStream (com.webpieces.http2engine.api.error.ShutdownStream)5 MockStreamWriter (org.webpieces.http2client.mock.MockStreamWriter)5 Http2Push (com.webpieces.hpack.api.dto.Http2Push)2 Http2Frame (com.webpieces.http2parser.api.dto.lib.Http2Frame)2 ByteBuffer (java.nio.ByteBuffer)2 ResponseStream (org.webpieces.frontend2.api.ResponseStream)2 Cancel (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.Cancel)2 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)2 Http2Response (com.webpieces.hpack.api.dto.Http2Response)1 HeaderSettings (com.webpieces.http2engine.impl.shared.data.HeaderSettings)1 CancelReason (com.webpieces.http2parser.api.dto.CancelReason)1 CancelReasonCode (com.webpieces.http2parser.api.dto.error.CancelReasonCode)1