MINOR: qpack: add comments and remove a useless trace
Add comments on the decoding function to facilitate code analysis.
Also remove the qpack_debug_hexdump() which prints the whole left buffer
on each header parsing. With large HEADERS frame payload, QPACK traces
are complicated to debug with this statement.
diff --git a/include/haproxy/qpack-dec.h b/include/haproxy/qpack-dec.h
index b847c80..991e1a9 100644
--- a/include/haproxy/qpack-dec.h
+++ b/include/haproxy/qpack-dec.h
@@ -29,11 +29,11 @@
*Nothing to see with the RFC.
*/
enum {
- QPACK_ERR_NONE = 0,
- QPACK_ERR_RIC,
- QPACK_ERR_DB,
- QPACK_ERR_TRUNCATED,
- QPACK_ERR_HUFFMAN,
+ QPACK_ERR_NONE = 0, /* no error */
+ QPACK_ERR_RIC, /* cannot decode Required Insert Count prefix field */
+ QPACK_ERR_DB, /* cannot decode Delta Base prefix field */
+ QPACK_ERR_TRUNCATED, /* truncated stream */
+ QPACK_ERR_HUFFMAN, /* huffman decoding error */
};
struct qpack_dec {
diff --git a/src/qpack-dec.c b/src/qpack-dec.c
index 3ca2eda..82ffd81 100644
--- a/src/qpack-dec.c
+++ b/src/qpack-dec.c
@@ -181,8 +181,13 @@
return 0;
}
-/* Decode a field section from <len> bytes length <raw> buffer.
- * Produces the output into <tmp> buffer.
+/* Decode a field section from the <raw> buffer of <len> bytes. Each parsed
+ * header is inserted into <list> and uses <tmp> as a storage for some elements
+ * pointing into it. An end marker is inserted at the end of the list with
+ * empty strings as name/value.
+ *
+ * Returns 0 on success. In case of error, a negative code QPACK_ERR_* is
+ * returned.
*/
int qpack_decode_fs(const unsigned char *raw, size_t len, struct buffer *tmp,
struct http_hdr *list)
@@ -195,6 +200,7 @@
qpack_debug_hexdump(stderr, "[QPACK-DEC-FS] ", (const char *)raw, 0, len);
+ /* parse field section prefix */
ret = qpack_decode_fs_pfx(&enc_ric, &db, &s, &raw, &len);
if (ret < 0) {
qpack_debug_printf(stderr, "##ERR@%d(%d)\n", __LINE__, ret);
@@ -206,9 +212,10 @@
(unsigned long long)enc_ric, (unsigned long long)db, !!s);
/* Decode field lines */
while (len) {
- qpack_debug_hexdump(stderr, "raw ", (const char *)raw, 0, len);
+ /* parse field line representation */
efl_type = *raw & QPACK_EFL_BITMASK;
qpack_debug_printf(stderr, "efl_type=0x%02x\n", efl_type);
+
if (efl_type == QPACK_LFL_WPBNM) {
/* Literal field line with post-base name reference */
uint64_t index __maybe_unused, length;