use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class TestC4FrameSizeAndHeaders method createInterleavedFrames.
private List<Http2Frame> createInterleavedFrames() {
Http2Response response1 = new Http2Response();
response1.setStreamId(1);
response1.setEndOfStream(true);
fillHeaders(response1);
HeaderEncoding encoding = new HeaderEncoding();
List<Http2Frame> frames1 = encoding.translateToFrames(localSettings.getMaxFrameSize(), new Encoder(localSettings.getHeaderTableSize()), response1);
Http2Response response2 = new Http2Response();
response2.setStreamId(3);
response1.setEndOfStream(true);
response2.addHeader(new Http2Header(Http2HeaderName.ACCEPT, "value"));
List<Http2Frame> frames2 = encoding.translateToFrames(localSettings.getMaxFrameSize(), new Encoder(localSettings.getHeaderTableSize()), response2);
List<Http2Frame> frames = new ArrayList<>();
frames.addAll(frames1);
frames.add(1, frames2.get(0));
return frames;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class HpackParserImpl method createHeadersData.
private DataWrapper createHeadersData(MarshalStateImpl state, Http2Headers headers) {
long maxFrameSize = state.getMaxRemoteFrameSize();
Encoder encoder = state.getEncoder();
List<Http2Frame> headerFrames = encoding.translateToFrames(maxFrameSize, encoder, headers);
return translate(headerFrames);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame 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 = DATA_GEN.emptyWrapper();
if (castFrame.getDebugData() != null)
debug = castFrame.getDebugData();
DataWrapper payload = DATA_GEN.chainDataWrappers(DATA_GEN.wrapByteBuffer(prelude), debug);
return super.marshalFrame(frame, (byte) 0, payload);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class PingMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
if (frame.getStreamId() != 0)
throw new IllegalArgumentException("PingFrame can never be any other stream id except 0 which is already set");
PingFrame ping = (PingFrame) frame;
ByteBuffer payload = bufferPool.nextBuffer(8);
payload.putLong(ping.getOpaqueData());
payload.flip();
DataWrapper dataPayload = DATA_GEN.wrapByteBuffer(payload);
byte value = 0x0;
if (ping.isPingResponse())
value |= 0x1;
return marshalFrame(frame, value, dataPayload);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class PriorityMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
PriorityFrame castFrame = (PriorityFrame) frame;
PriorityDetails priorityDetails = castFrame.getPriorityDetails();
DataWrapper payload = marshalPriorityDetails(bufferPool, priorityDetails, frame);
return super.marshalFrame(frame, (byte) 0, payload);
}
Aggregations