use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg in project webpieces by deanhiller.
the class MockHttp2Channel method write.
@SuppressWarnings("unchecked")
@Override
public XFuture<Void> write(ByteBuffer b) {
if (!prefaceReceived) {
// copy and store preface
ByteBuffer prefaceBuffer = ByteBuffer.allocate(b.remaining());
prefaceBuffer.put(b);
prefaceReceived = true;
Preface preface = new Preface(prefaceBuffer);
List<Http2Msg> msgs = new ArrayList<>();
msgs.add(preface);
return (XFuture<Void>) super.calledMethod(Method.INCOMING_FRAME, msgs);
}
return processData(b);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg in project webpieces by deanhiller.
the class MockHttp2Channel method processData.
@SuppressWarnings("unchecked")
private XFuture<Void> processData(ByteBuffer b) {
DataWrapper data = dataGen.wrapByteBuffer(b);
parser.unmarshal(unmarshalState, data);
List<Http2Msg> parsedFrames = unmarshalState.getParsedFrames();
return (XFuture<Void>) super.calledMethod(Method.INCOMING_FRAME, parsedFrames);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg in project webpieces by deanhiller.
the class Http11ToHttp2 method translateChunk.
private static Http2Msg translateChunk(HttpChunk payload, boolean eos) {
DataFrame frame = new DataFrame();
frame.setData(payload.getBodyNonNull());
frame.setEndOfStream(eos);
return frame;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg in project webpieces by deanhiller.
the class HpackParserImpl method processFrameImpl.
private void processFrameImpl(UnmarshalStateImpl state, Http2Frame frame) {
List<HasHeaderFragment> headerFragList = state.getHeadersToCombine();
if (frame instanceof HasHeaderFragment) {
HasHeaderFragment headerFrame = (HasHeaderFragment) frame;
headerFragList.add(headerFrame);
validateHeader(state, headerFrame);
if (headerFrame.isEndHeaders())
combineAndSendHeadersToClient(state);
return;
} else if (headerFragList.size() > 0) {
throw new ConnectionException(CancelReasonCode.HEADERS_MIXED_WITH_FRAMES, state.getLogId(), frame.getStreamId(), "Parser in the middle of accepting headers(spec " + "doesn't allow frames between header fragments). frame=" + frame + " list=" + headerFragList);
}
if (frame instanceof UnknownFrame && ignoreUnkownFrames) {
// do nothing
} else if (frame instanceof Http2Msg) {
state.addParsedMessage((Http2Msg) frame);
} else {
throw new IllegalStateException("bug forgot support for frame=" + frame);
}
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg in project webpieces by deanhiller.
the class AbstractFrontendHttp2Test method simulateClientSendingPrefaceAndSettings.
protected void simulateClientSendingPrefaceAndSettings() {
// this method is overloaded by one test
HeaderSettings settings = Http2Requests.createSomeSettings();
mockChannel.sendPrefaceAndSettings(HeaderSettings.createSettingsFrame(settings));
List<Http2Msg> frames = mockChannel.getFramesAndClear();
Assert.assertEquals(2, frames.size());
}
Aggregations