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);
}
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;
}
Aggregations