uint32_t HPACKDecoder::decode(Cursor& cursor, uint32_t totalBytes, headers_t& headers) { uint32_t emittedSize = 0; HPACKDecodeBuffer dbuf(getHuffmanTree(), cursor, totalBytes); while (!hasError() && !dbuf.empty()) { emittedSize += decodeHeader(dbuf, &headers); if (emittedSize > maxUncompressed_) { LOG(ERROR) << "exceeded uncompressed size limit of " << maxUncompressed_ << " bytes"; err_ = DecodeError::HEADERS_TOO_LARGE; return dbuf.consumedBytes(); } } if (version_ != Version::HPACK05) { return dbuf.consumedBytes(); } emittedSize += emitRefset(headers); // the emitted bytes from the refset are bounded by the size of the table, // but adding the check just for uniformity if (emittedSize > maxUncompressed_) { LOG(ERROR) << "exceeded uncompressed size limit of " << maxUncompressed_ << " bytes"; err_ = DecodeError::HEADERS_TOO_LARGE; } return dbuf.consumedBytes(); }
uint32_t HPACKDecoder::decode(Cursor& cursor, uint32_t totalBytes, headers_t& headers) { uint32_t emittedSize = 0; HPACKDecodeBuffer dbuf(getHuffmanTree(), cursor, totalBytes, maxUncompressed_); while (!hasError() && !dbuf.empty()) { emittedSize += decodeHeader(dbuf, &headers); if (emittedSize > maxUncompressed_) { LOG(ERROR) << "exceeded uncompressed size limit of " << maxUncompressed_ << " bytes"; err_ = DecodeError::HEADERS_TOO_LARGE; return dbuf.consumedBytes(); } } return dbuf.consumedBytes(); }
uint32_t HPACKDecoder::decodeStreaming( Cursor& cursor, uint32_t totalBytes, HeaderCodec::StreamingCallback* streamingCb) { uint32_t emittedSize = 0; streamingCb_ = streamingCb; HPACKDecodeBuffer dbuf(getHuffmanTree(), cursor, totalBytes, maxUncompressed_); while (!hasError() && !dbuf.empty()) { emittedSize += decodeHeader(dbuf, nullptr); if (emittedSize > maxUncompressed_) { LOG(ERROR) << "exceeded uncompressed size limit of " << maxUncompressed_ << " bytes"; err_ = HPACK::DecodeError::HEADERS_TOO_LARGE; return dbuf.consumedBytes(); } } return dbuf.consumedBytes(); }