MINOR: hpack: provide a function to encode a long indexed header

For long header values whose index is known, hpack_encodde_long_idx()
may now be used. This function emits the short index and follows with
the header's value.
diff --git a/include/common/hpack-enc.h b/include/common/hpack-enc.h
index a0fc0f3..4e60104 100644
--- a/include/common/hpack-enc.h
+++ b/include/common/hpack-enc.h
@@ -29,6 +29,7 @@
 #define _COMMON_HPACK_ENC_H
 
 #include <stdint.h>
+#include <string.h>
 #include <common/buf.h>
 #include <common/config.h>
 #include <common/ist.h>
@@ -97,4 +98,29 @@
 	return 1;
 }
 
+/* Tries to encode header field index <idx> with long value <val> into the
+ * aligned buffer <out>. Returns non-zero on success, 0 on failure (buffer
+ * full). The caller is responsible for ensuring <idx> is lower than 64 (static
+ * list only), and that the buffer is aligned (head==0).
+ */
+static inline int hpack_encode_long_idx(struct buffer *out, int idx, struct ist val)
+{
+	int len = out->data;
+
+	if (!hpack_len_to_bytes(val.len) ||
+	    1 + len + hpack_len_to_bytes(val.len) + val.len > out->size)
+		return 0;
+
+	/* emit literal with indexing (7541#6.2.1) :
+	 * [ 0 | 1 | Index (6+) ]
+	 */
+	out->area[len++] = idx | 0x40;
+	len = hpack_encode_len(out->area, len, val.len);
+	memcpy(out->area + len, val.ptr, val.len);
+	len += val.len;
+
+	out->data = len;
+	return 1;
+}
+
 #endif /* _COMMON_HPACK_ENC_H */