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);
}
Aggregations