nsresult Http2Decompressor::DecodeHeaderBlock(const uint8_t *data, uint32_t datalen, nsACString &output) { mAlternateReferenceSet.Clear(); mOffset = 0; mData = data; mDataLen = datalen; mOutput = &output; mOutput->Truncate(); mHeaderStatus.Truncate(); mHeaderHost.Truncate(); mHeaderScheme.Truncate(); mHeaderPath.Truncate(); mHeaderMethod.Truncate(); nsresult rv = NS_OK; while (NS_SUCCEEDED(rv) && (mOffset < datalen)) { if (mData[mOffset] & 0x80) { rv = DoIndexed(); LOG(("Decompressor state after indexed")); } else if (mData[mOffset] & 0x40) { rv = DoLiteralWithIncremental(); LOG(("Decompressor state after literal with incremental")); } else if (mData[mOffset] & 0x20) { rv = DoContextUpdate(); LOG(("Decompressor state after context update")); } else if (mData[mOffset] & 0x10) { rv = DoLiteralNeverIndexed(); LOG(("Decompressor state after literal never index")); } else { rv = DoLiteralWithoutIndex(); LOG(("Decompressor state after literal without index")); } DumpState(); } // after processing the input the decompressor comapres the alternate // set to the inherited reference set and generates headers for // anything implicit in reference - alternate. uint32_t setLen = mReferenceSet.Length(); for (uint32_t index = 0; index < setLen; ++index) { if (!mAlternateReferenceSet.Contains(mReferenceSet[index])) { LOG(("HTTP decompressor carryover in reference set with index %u %s %s\n", mReferenceSet[index], mHeaderTable[mReferenceSet[index]]->mName.get(), mHeaderTable[mReferenceSet[index]]->mValue.get())); OutputHeader(mReferenceSet[index]); } } mAlternateReferenceSet.Clear(); return rv; }
nsresult Http2Decompressor::DecodeHeaderBlock(const uint8_t *data, uint32_t datalen, nsACString &output, bool isPush) { mOffset = 0; mData = data; mDataLen = datalen; mOutput = &output; mOutput->Truncate(); mHeaderStatus.Truncate(); mHeaderHost.Truncate(); mHeaderScheme.Truncate(); mHeaderPath.Truncate(); mHeaderMethod.Truncate(); mSeenNonColonHeader = false; mIsPush = isPush; nsresult rv = NS_OK; while (NS_SUCCEEDED(rv) && (mOffset < datalen)) { if (mData[mOffset] & 0x80) { rv = DoIndexed(); LOG(("Decompressor state after indexed")); } else if (mData[mOffset] & 0x40) { rv = DoLiteralWithIncremental(); LOG(("Decompressor state after literal with incremental")); } else if (mData[mOffset] & 0x20) { rv = DoContextUpdate(); LOG(("Decompressor state after context update")); } else if (mData[mOffset] & 0x10) { rv = DoLiteralNeverIndexed(); LOG(("Decompressor state after literal never index")); } else { rv = DoLiteralWithoutIndex(); LOG(("Decompressor state after literal without index")); } DumpState(); } return rv; }