Search in sources :

Example 16 with Http2Frame

use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame 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 17 with Http2Frame

use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.

the class HpackParserImpl method unmarshalImpl.

private UnmarshalStateImpl unmarshalImpl(UnmarshalStateImpl state, DataWrapper newData) {
    // reset any parsed frames
    state.clearParsedFrames();
    state.addToDataToParseSize(newData.getReadableSize());
    Http2Memento result = parser.parse(state.getLowLevelState(), newData);
    state.addHalfParsedSize(result.getNumBytesJustParsed());
    List<Http2Frame> parsedFrames = result.getParsedFrames();
    for (Http2Frame frame : parsedFrames) {
        processFrame(state, frame);
    }
    return state;
}
Also used : Http2Memento(com.webpieces.http2parser.api.Http2Memento) Http2Frame(com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame)

Example 18 with Http2Frame

use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.

the class HpackParserImpl method createPushPromiseData.

private DataWrapper createPushPromiseData(MarshalStateImpl state, Http2Push p) {
    long maxFrameSize = state.getMaxRemoteFrameSize();
    Encoder encoder = state.getEncoder();
    List<Http2Frame> headerFrames = encoding.translateToFrames(maxFrameSize, encoder, p);
    return translate(headerFrames);
}
Also used : Encoder(com.twitter.hpack.Encoder) Http2Frame(com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame)

Example 19 with Http2Frame

use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame in project webpieces by deanhiller.

the class HpackParserImpl method translate.

private DataWrapper translate(List<Http2Frame> headerFrames) {
    DataWrapper allData = DataWrapperGeneratorFactory.EMPTY;
    for (Http2Frame f : headerFrames) {
        DataWrapper frameData = parser.marshal(f);
        allData = dataGen.chainDataWrappers(allData, frameData);
    }
    return allData;
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) Http2Frame(com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame)

Example 20 with Http2Frame

use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame 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);
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) ContinuationFrame(com.webpieces.http2.api.dto.lowlevel.ContinuationFrame)

Aggregations

DataWrapper (org.webpieces.data.api.DataWrapper)14 Http2Frame (com.webpieces.http2.api.dto.lowlevel.lib.Http2Frame)11 ByteBuffer (java.nio.ByteBuffer)5 Encoder (com.twitter.hpack.Encoder)4 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)4 ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)3 GoAwayFrame (com.webpieces.http2.api.dto.lowlevel.GoAwayFrame)3 ArrayList (java.util.ArrayList)3 HeaderEncoding (com.webpieces.hpack.impl.HeaderEncoding)2 Http2Response (com.webpieces.http2.api.dto.highlevel.Http2Response)2 ContinuationFrame (com.webpieces.http2.api.dto.lowlevel.ContinuationFrame)2 HeadersFrame (com.webpieces.http2.api.dto.lowlevel.HeadersFrame)2 PushPromiseFrame (com.webpieces.http2.api.dto.lowlevel.PushPromiseFrame)2 HasHeaderFragment (com.webpieces.http2.api.dto.lowlevel.lib.HasHeaderFragment)2 PriorityDetails (com.webpieces.http2.api.dto.lowlevel.lib.PriorityDetails)2 Test (org.junit.Test)2 Http2Request (com.webpieces.http2.api.dto.highlevel.Http2Request)1 DataFrame (com.webpieces.http2.api.dto.lowlevel.DataFrame)1 PingFrame (com.webpieces.http2.api.dto.lowlevel.PingFrame)1 PriorityFrame (com.webpieces.http2.api.dto.lowlevel.PriorityFrame)1