use of com.webpieces.http2.api.dto.lowlevel.ContinuationFrame in project webpieces by deanhiller.
the class HpackParserImpl method validateHeader.
private void validateHeader(UnmarshalStateImpl state, HasHeaderFragment lowLevelFrame) {
List<HasHeaderFragment> list = state.getHeadersToCombine();
HasHeaderFragment first = list.get(0);
int streamId = first.getStreamId();
if (first instanceof PushPromiseFrame) {
PushPromiseFrame f = (PushPromiseFrame) first;
streamId = f.getPromisedStreamId();
}
String logId = state.getLogId();
if (list.size() == 1) {
if (!(first instanceof HeadersFrame) && !(first instanceof PushPromiseFrame))
throw new ConnectionException(CancelReasonCode.HEADERS_MIXED_WITH_FRAMES, logId, lowLevelFrame.getStreamId(), "First has header frame must be HeadersFrame or PushPromiseFrame first frame=" + first);
} else if (streamId != lowLevelFrame.getStreamId()) {
throw new ConnectionException(CancelReasonCode.HEADERS_MIXED_WITH_FRAMES, logId, lowLevelFrame.getStreamId(), "Headers/continuations from two different streams per spec cannot be" + " interleaved. frames=" + list);
} else if (!(lowLevelFrame instanceof ContinuationFrame)) {
throw new ConnectionException(CancelReasonCode.HEADERS_MIXED_WITH_FRAMES, logId, lowLevelFrame.getStreamId(), "Must be continuation frame and wasn't. frames=" + list);
}
}
use of com.webpieces.http2.api.dto.lowlevel.ContinuationFrame in project webpieces by deanhiller.
the class ContinuationMarshaller method unmarshal.
@Override
public AbstractHttp2Frame unmarshal(Http2MementoImpl state, DataWrapper framePayloadData) {
ContinuationFrame frame = new ContinuationFrame();
super.unmarshalFrame(state, frame);
byte flags = state.getFrameHeaderData().getFlagsByte();
frame.setEndHeaders((flags & 0x4) == 0x4);
frame.setHeaderFragment(framePayloadData);
return frame;
}
use of com.webpieces.http2.api.dto.lowlevel.ContinuationFrame in project webpieces by deanhiller.
the class ContinuationMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
ContinuationFrame castFrame = (ContinuationFrame) frame;
byte value = 0x0;
if (castFrame.isEndHeaders())
value |= 0x4;
DataWrapper dataPayload = castFrame.getHeaderFragment();
return super.marshalFrame(frame, value, dataPayload);
}
use of com.webpieces.http2.api.dto.lowlevel.ContinuationFrame in project webpieces by deanhiller.
the class HeaderEncoding method createHeaderFrames.
private List<Http2Frame> createHeaderFrames(HasHeaderFragment initialFrame, List<Http2Header> headers, Encoder encoder, long maxFrameSize) {
int maxSize = (int) maxFrameSize;
if (maxFrameSize > Integer.MAX_VALUE)
throw new IllegalStateException("max frame size too large for this hpack library");
List<Http2Frame> headerFrames = new LinkedList<>();
DataWrapper serializedHeaders = serializeHeaders(encoder, headers);
HasHeaderFragment currentFrame = initialFrame;
HasHeaderFragment lastFrame = currentFrame;
DataWrapper dataLeftOver = serializedHeaders;
while (dataLeftOver.getReadableSize() > 0) {
lastFrame = currentFrame;
int splitSize = Math.min(dataLeftOver.getReadableSize(), maxSize);
List<? extends DataWrapper> split = dataGen.split(dataLeftOver, splitSize);
DataWrapper fragment = split.get(0);
currentFrame.setHeaderFragment(fragment);
headerFrames.add(currentFrame);
currentFrame = new ContinuationFrame();
currentFrame.setStreamId(initialFrame.getStreamId());
dataLeftOver = split.get(1);
}
// last frame is currentFrame so set end header
lastFrame.setEndHeaders(true);
return headerFrames;
}
Aggregations