Search in sources :

Example 1 with Decoder

use of com.twitter.hpack.Decoder in project webpieces by deanhiller.

the class HpackParserImpl method prepareToUnmarshal.

@Override
public UnmarshalState prepareToUnmarshal(String logId, int maxHeaderSize, int maxHeaderTableSize, long localMaxFrameSize) {
    Decoder decoder = new Decoder(maxHeaderSize, maxHeaderTableSize);
    Http2Memento result = parser.prepareToParse(localMaxFrameSize);
    return new UnmarshalStateImpl(logId, result, decoding, decoder);
}
Also used : Decoder(com.twitter.hpack.Decoder) Http2Memento(com.webpieces.http2parser.api.Http2Memento)

Example 2 with Decoder

use of com.twitter.hpack.Decoder in project webpieces by deanhiller.

the class HeaderDecoding method decodeImpl.

private List<Http2Header> decodeImpl(UnmarshalStateImpl state, DataWrapper data, int streamId, Consumer<Http2Header> knownHeaders) throws IOException {
    List<Http2Header> headers = new ArrayList<>();
    byte[] bytes = data.createByteArray();
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    Decoder decoder = state.getDecoder();
    //TODO(dhiller): make this an async syncrhonized block instead so threads can keep running!!!
    synchronized (decoder) {
        decoder.decode(in, (n, v, s) -> addToHeaders(headers, knownHeaders, n, v, s, state.getLogId(), streamId));
        decoder.endHeaderBlock();
    }
    if (data.getReadableSize() > 0 && headers.size() == 0)
        throw new ConnectionException(CancelReasonCode.COMPRESSION_ERROR, state.getLogId(), streamId, "Header data came in, but no headers came out");
    return headers;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) ArrayList(java.util.ArrayList) Decoder(com.twitter.hpack.Decoder) ConnectionException(com.webpieces.http2parser.api.dto.error.ConnectionException)

Aggregations

Decoder (com.twitter.hpack.Decoder)2 Http2Memento (com.webpieces.http2parser.api.Http2Memento)1 ConnectionException (com.webpieces.http2parser.api.dto.error.ConnectionException)1 Http2Header (com.webpieces.http2parser.api.dto.lib.Http2Header)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1