Search in sources :

Example 11 with Http2Msg

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);
}
Also used : XFuture(org.webpieces.util.futures.XFuture) ArrayList(java.util.ArrayList) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) ByteBuffer(java.nio.ByteBuffer)

Example 12 with Http2Msg

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);
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) XFuture(org.webpieces.util.futures.XFuture) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)

Example 13 with Http2Msg

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;
}
Also used : DataFrame(com.webpieces.http2.api.dto.lowlevel.DataFrame)

Example 14 with Http2Msg

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);
    }
}
Also used : HasHeaderFragment(com.webpieces.http2.api.dto.lowlevel.lib.HasHeaderFragment) UnknownFrame(com.webpieces.http2.api.dto.lowlevel.UnknownFrame) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException)

Example 15 with Http2Msg

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());
}
Also used : HeaderSettings(com.webpieces.http2engine.impl.shared.data.HeaderSettings) Http2Msg(com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)

Aggregations

Http2Msg (com.webpieces.http2.api.dto.lowlevel.lib.Http2Msg)27 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)12 Test (org.junit.Test)12 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)8 StreamWriter (com.webpieces.http2.api.streaming.StreamWriter)8 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)7 DataWrapper (org.webpieces.data.api.DataWrapper)7 XFuture (org.webpieces.util.futures.XFuture)7 HeaderSettings (com.webpieces.http2engine.impl.shared.data.HeaderSettings)6 SettingsFrame (com.webpieces.http2.api.dto.lowlevel.SettingsFrame)5 Http2Push (com.webpieces.http2.api.dto.highlevel.Http2Push)4 PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)4 ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)3 Http2Headers (com.webpieces.http2.api.dto.highlevel.Http2Headers)3 Http2Trailers (com.webpieces.http2.api.dto.highlevel.Http2Trailers)3 MockStreamWriter (org.webpieces.httpfrontend2.api.mock2.MockStreamWriter)3 UnmarshalState (com.webpieces.hpack.api.UnmarshalState)2 CancelReasonCode (com.webpieces.http2.api.dto.error.CancelReasonCode)2 StreamException (com.webpieces.http2.api.dto.error.StreamException)2 CancelReason (com.webpieces.http2.api.dto.lowlevel.CancelReason)2