Search in sources :

Example 11 with AbstractHttp2Frame

use of com.webpieces.http2.api.dto.lowlevel.lib.AbstractHttp2Frame in project webpieces by deanhiller.

the class DataMarshaller method unmarshal.

@Override
public AbstractHttp2Frame unmarshal(Http2MementoImpl state, DataWrapper framePayloadData) {
    DataFrame frame = new DataFrame();
    super.unmarshalFrame(state, frame);
    byte flags = state.getFrameHeaderData().getFlagsByte();
    frame.setEndOfStream((flags & 0x1) == 0x1);
    boolean isPadded = (flags & 0x8) == 0x8;
    DataSplit split = PaddingUtil.extractPayloadAndPadding(isPadded, framePayloadData, frame.getStreamId());
    frame.setData(split.getPayload());
    frame.setPadding(split.getPadding());
    if (frame.getStreamId() == 0)
        throw new ConnectionException(CancelReasonCode.INVALID_STREAM_ID, frame.getStreamId(), "headers frame had invalid stream id=" + frame.getStreamId());
    return frame;
}
Also used : DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame) DataSplit(com.webpieces.http2parser.impl.DataSplit) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException)

Aggregations

ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)9 ByteBuffer (java.nio.ByteBuffer)8 FrameHeaderData (com.webpieces.http2parser.impl.FrameHeaderData)5 DataSplit (com.webpieces.http2parser.impl.DataSplit)3 PriorityDetails (com.webpieces.http2.api.dto.lowlevel.lib.PriorityDetails)2 DataWrapper (org.webpieces.data.api.DataWrapper)2 ContinuationFrame (com.webpieces.http2.api.dto.lowlevel.ContinuationFrame)1 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)1 GoAwayFrame (com.webpieces.http2.api.dto.lowlevel.GoAwayFrame)1 HeadersFrame (com.webpieces.http2.api.dto.lowlevel.HeadersFrame)1 PingFrame (com.webpieces.http2.api.dto.lowlevel.PingFrame)1 PriorityFrame (com.webpieces.http2.api.dto.lowlevel.PriorityFrame)1 PushPromiseFrame (com.webpieces.http2.api.dto.lowlevel.PushPromiseFrame)1 RstStreamFrame (com.webpieces.http2.api.dto.lowlevel.RstStreamFrame)1 SettingsFrame (com.webpieces.http2.api.dto.lowlevel.SettingsFrame)1 UnknownFrame (com.webpieces.http2.api.dto.lowlevel.UnknownFrame)1 WindowUpdateFrame (com.webpieces.http2.api.dto.lowlevel.WindowUpdateFrame)1 AbstractHttp2Frame (com.webpieces.http2.api.dto.lowlevel.lib.AbstractHttp2Frame)1 Http2FrameType (com.webpieces.http2.api.dto.lowlevel.lib.Http2FrameType)1 Http2Setting (com.webpieces.http2.api.dto.lowlevel.lib.Http2Setting)1