use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class TestS4FrameSizeAndHeaders 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 SettingsMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
if (frame.getStreamId() != 0)
throw new IllegalArgumentException("SettingsFrame can never be any other stream id except 0 which is already set");
SettingsFrame castFrame = (SettingsFrame) frame;
for (Http2Setting setting : castFrame.getSettings()) {
validate(setting);
}
byte flags = 0x0;
if (castFrame.isAck())
flags |= 0x1;
DataWrapper dataPayload;
if (castFrame.isAck()) {
if (castFrame.getSettings() != null && castFrame.getSettings().size() > 0)
throw new IllegalArgumentException("Ack SettingsFrame can not have setting in it");
dataPayload = DATA_GEN.emptyWrapper();
} else if (castFrame.getSettings().size() == 0) {
dataPayload = DATA_GEN.emptyWrapper();
} else {
List<Http2Setting> settings = castFrame.getSettings();
dataPayload = marshalOut(settings);
}
return super.marshalFrame(frame, flags, dataPayload);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class PushPromiseMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
PushPromiseFrame castFrame = (PushPromiseFrame) frame;
int originalStreamId = castFrame.getPromisedStreamId();
int streamId = originalStreamId & 0x7FFFFFFF;
if (streamId != originalStreamId)
throw new RuntimeException("your promisedStreamId is too large per spec. frame=" + frame);
int paddingSize = castFrame.getPadding().getReadableSize();
byte value = 0x0;
if (castFrame.isEndHeaders())
value |= 0x4;
if (paddingSize > 0)
value |= 0x8;
ByteBuffer prelude = bufferPool.nextBuffer(4);
prelude.putInt(castFrame.getPromisedStreamId());
prelude.flip();
DataWrapper headersDW = castFrame.getHeaderFragment();
DataWrapper finalDW = DATA_GEN.chainDataWrappers(DATA_GEN.wrapByteBuffer(prelude), headersDW);
DataWrapper payload = PaddingUtil.padDataIfNeeded(finalDW, castFrame.getPadding());
return super.marshalFrame(frame, value, payload);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class RstStreamMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
RstStreamFrame castFrame = (RstStreamFrame) frame;
ByteBuffer payload = bufferPool.nextBuffer(4);
UnsignedData.putUnsignedInt(payload, castFrame.getErrorCode());
payload.flip();
DataWrapper dataPayload = DATA_GEN.wrapByteBuffer(payload);
return super.marshalFrame(frame, (byte) 0, dataPayload);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.
the class WindowUpdateMarshaller method marshal.
@Override
public DataWrapper marshal(Http2Frame frame) {
WindowUpdateFrame castFrame = (WindowUpdateFrame) frame;
ByteBuffer payload = bufferPool.nextBuffer(4).putInt(castFrame.getWindowSizeIncrement());
payload.flip();
DataWrapper dataPayload = DATA_GEN.wrapByteBuffer(payload);
return super.marshalFrame(frame, (byte) 0, dataPayload);
}
Aggregations