Bug 1014600 part 1 - Improve HPACK logging. r=mcmanus

This commit is contained in:
Nicholas Hurley 2014-07-11 09:48:32 -07:00
Родитель e7024b77c9
Коммит 9f15f3e4c3
1 изменённых файлов: 17 добавлений и 18 удалений

Просмотреть файл

@ -298,10 +298,12 @@ Http2BaseCompressor::DumpState()
}
LOG(("Header Table"));
length = mHeaderTable.VariableLength();
length = mHeaderTable.Length();
uint32_t variableLength = mHeaderTable.VariableLength();
for (i = 0; i < length; ++i) {
const nvPair *pair = mHeaderTable[i];
LOG(("index %u: %s %s", i, pair->mName.get(), pair->mValue.get()));
LOG(("%sindex %u: %s %s", i < variableLength ? "" : "static ", i,
pair->mName.get(), pair->mValue.get()));
}
}
@ -511,8 +513,10 @@ nsresult
Http2Decompressor::OutputHeader(uint32_t index)
{
// bounds check
if (mHeaderTable.Length() <= index)
if (mHeaderTable.Length() <= index) {
LOG(("Http2Decompressor::OutputHeader index too large %u", index));
return NS_ERROR_ILLEGAL_VALUE;
}
return OutputHeader(mHeaderTable[index]->mName,
mHeaderTable[index]->mValue);
@ -718,10 +722,11 @@ Http2Decompressor::MakeRoom(uint32_t amount)
uint32_t removedCount = 0;
while (mHeaderTable.VariableLength() && ((mHeaderTable.ByteCount() + amount) > mMaxBuffer)) {
uint32_t index = mHeaderTable.VariableLength() - 1;
LOG(("HTTP decompressor header table index %u %s %s removed for size.\n",
index, mHeaderTable[index]->mName.get(),
mHeaderTable[index]->mValue.get()));
mHeaderTable.RemoveElement();
++removedCount;
LOG(("HTTP decompressor header table index %u removed for size.\n",
index));
}
// adjust references to header table
@ -772,6 +777,8 @@ Http2Decompressor::DoIndexed()
return rv;
}
LOG(("HTTP decompressor inserting static entry %u %s %s into dynamic table",
index, pair->mName.get(), pair->mValue.get()));
MakeRoom(room);
mHeaderTable.AddElement(pair->mName, pair->mValue);
IncrementReferenceSetIndices();
@ -812,9 +819,13 @@ Http2Decompressor::DoLiteralInternal(nsACString &name, nsACString &value,
rv = CopyStringFromInput(nameLen, name);
}
}
LOG(("Http2Decompressor::DoLiteralInternal literal name %s",
name.BeginReading()));
} else {
// name is from headertable
rv = CopyHeaderString(index - 1, name);
LOG(("Http2Decompressor::DoLiteralInternal indexed name %d %s",
index, name.BeginReading()));
}
if (NS_FAILED(rv))
return rv;
@ -832,6 +843,7 @@ Http2Decompressor::DoLiteralInternal(nsACString &name, nsACString &value,
}
if (NS_FAILED(rv))
return rv;
LOG(("Http2Decompressor::DoLiteralInternal value %s", value.BeginReading()));
return NS_OK;
}
@ -1314,9 +1326,6 @@ Http2Compressor::HuffmanAppend(const nsCString &value)
uint8_t idx = static_cast<uint8_t>(value[i]);
uint8_t huffLength = HuffmanOutgoing[idx].mLength;
uint32_t huffValue = HuffmanOutgoing[idx].mValue;
LOG(("Http2Compressor::HuffmanAppend %p character=%c (%d) value=%X "
"length=%d offset=%d bitsLeft=%d\n", this, value[i], idx, huffValue,
huffLength, offset, bitsLeft));
if (bitsLeft < 8) {
// Fill in the least significant <bitsLeft> bits of the previous byte
@ -1330,8 +1339,6 @@ Http2Compressor::HuffmanAppend(const nsCString &value)
}
val &= ((1 << bitsLeft) - 1);
offset = buf.Length() - 1;
LOG(("Http2Compressor::HuffmanAppend %p appending %X to byte %d.",
this, val, offset));
startByte = reinterpret_cast<unsigned char *>(buf.BeginWriting()) + offset;
*startByte = *startByte | static_cast<uint8_t>(val & 0xFF);
if (huffLength >= bitsLeft) {
@ -1341,8 +1348,6 @@ Http2Compressor::HuffmanAppend(const nsCString &value)
bitsLeft -= huffLength;
huffLength = 0;
}
LOG(("Http2Compressor::HuffmanAppend %p encoded length remaining=%d, "
"bitsLeft=%d\n", this, huffLength, bitsLeft));
}
while (huffLength >= 8) {
@ -1350,8 +1355,6 @@ Http2Compressor::HuffmanAppend(const nsCString &value)
uint8_t val = ((huffValue & mask) >> (huffLength - 8)) & 0xFF;
buf.Append(reinterpret_cast<char *>(&val), 1);
huffLength -= 8;
LOG(("Http2Compressor::HuffmanAppend %p appended byte %X, encoded "
"length remaining=%d\n", this, val, huffLength));
}
if (huffLength) {
@ -1359,8 +1362,6 @@ Http2Compressor::HuffmanAppend(const nsCString &value)
bitsLeft = 8 - huffLength;
uint8_t val = (huffValue & ((1 << huffLength) - 1)) << bitsLeft;
buf.Append(reinterpret_cast<char *>(&val), 1);
LOG(("Http2Compressor::HuffmanAppend %p setting high %d bits of last "
"byte to %X. bitsLeft=%d.\n", this, huffLength, val, bitsLeft));
}
}
@ -1371,8 +1372,6 @@ Http2Compressor::HuffmanAppend(const nsCString &value)
offset = buf.Length() - 1;
startByte = reinterpret_cast<unsigned char *>(buf.BeginWriting()) + offset;
*startByte = *startByte | val;
LOG(("Http2Compressor::HuffmanAppend %p padded low %d bits of last byte "
"with %X", this, bitsLeft, val));
}
// Now we know how long our encoded string is, we can fill in our length