Search in sources :

Example 1 with Http2HeaderName

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

the class HpackParserImpl method combineAndSendHeadersToClient.

private void combineAndSendHeadersToClient(UnmarshalStateImpl state) {
    List<HasHeaderFragment> hasHeaderFragmentList = state.getHeadersToCombine();
    // Now we set the full header list on the first frame and just return that
    HasHeaderFragment firstFrame = hasHeaderFragmentList.get(0);
    DataWrapper allSerializedHeaders = dataGen.emptyWrapper();
    for (HasHeaderFragment iterFrame : hasHeaderFragmentList) {
        allSerializedHeaders = dataGen.chainDataWrappers(allSerializedHeaders, iterFrame.getHeaderFragment());
    }
    Map<Http2HeaderName, Http2Header> knownHeaders = new HashMap<>();
    List<Http2Header> headers = decoding.decode(state, allSerializedHeaders, firstFrame.getStreamId(), header -> knownHeaders.put(header.getKnownName(), header));
    if (firstFrame instanceof HeadersFrame) {
        HeadersFrame f = (HeadersFrame) firstFrame;
        Http2Headers fullHeaders = createCorrectType(knownHeaders, headers, state.getLogId(), f.getStreamId(), f.isEndOfStream());
        fullHeaders.setStreamId(f.getStreamId());
        fullHeaders.setPriorityDetails(f.getPriorityDetails());
        fullHeaders.setEndOfStream(f.isEndOfStream());
        state.addParsedMessage(fullHeaders);
    } else if (firstFrame instanceof PushPromiseFrame) {
        PushPromiseFrame f = (PushPromiseFrame) firstFrame;
        Http2Push fullHeaders = new Http2Push(headers);
        fullHeaders.setStreamId(f.getStreamId());
        fullHeaders.setPromisedStreamId(f.getPromisedStreamId());
        state.addParsedMessage(fullHeaders);
    }
    hasHeaderFragmentList.clear();
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) HasHeaderFragment(com.webpieces.http2.api.dto.lowlevel.lib.HasHeaderFragment) HashMap(java.util.HashMap) Http2Headers(com.webpieces.http2.api.dto.highlevel.Http2Headers) Http2HeaderName(com.webpieces.http2.api.dto.lowlevel.lib.Http2HeaderName) Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header) Http2Push(com.webpieces.http2.api.dto.highlevel.Http2Push) PushPromiseFrame(com.webpieces.http2.api.dto.lowlevel.PushPromiseFrame) HeadersFrame(com.webpieces.http2.api.dto.lowlevel.HeadersFrame)

Example 2 with Http2HeaderName

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

the class HeaderDecoding method addToHeaders.

private Object addToHeaders(List<Http2Header> headers, Consumer<Http2Header> knownHeaders, byte[] name, byte[] value, boolean sensitive, String logId, int streamId) {
    String h = new String(name);
    String v = new String(value);
    if (!h.equals(h.toLowerCase()))
        throw new ConnectionException(CancelReasonCode.HEADER_NOT_LOWER_CASE, logId, streamId, "header=" + h + " was not lower case in stream=" + streamId);
    Http2Header header = new Http2Header(h, v);
    headers.add(header);
    if (knownHeaders != null) {
        Http2HeaderName knownName = Http2HeaderName.lookup(h);
        if (knownName != null)
            knownHeaders.accept(header);
    }
    return null;
}
Also used : Http2Header(com.webpieces.http2.api.dto.lowlevel.lib.Http2Header) Http2HeaderName(com.webpieces.http2.api.dto.lowlevel.lib.Http2HeaderName) ConnectionException(com.webpieces.http2.api.dto.error.ConnectionException)

Aggregations

Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)2 Http2HeaderName (com.webpieces.http2.api.dto.lowlevel.lib.Http2HeaderName)2 ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)1 Http2Headers (com.webpieces.http2.api.dto.highlevel.Http2Headers)1 Http2Push (com.webpieces.http2.api.dto.highlevel.Http2Push)1 HeadersFrame (com.webpieces.http2.api.dto.lowlevel.HeadersFrame)1 PushPromiseFrame (com.webpieces.http2.api.dto.lowlevel.PushPromiseFrame)1 HasHeaderFragment (com.webpieces.http2.api.dto.lowlevel.lib.HasHeaderFragment)1 HashMap (java.util.HashMap)1 DataWrapper (org.webpieces.data.api.DataWrapper)1