aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Eric Anderson <ejona86@gmail.com>2015-02-10 09:27:47 -0800
committerGravatar Eric Anderson <ejona86@gmail.com>2015-02-10 09:27:47 -0800
commitc520f0991f579fd4c44d357b191fcdb66b89e87c (patch)
treed44a43d0e048e8824ba2307e466b4b3b22679bb6
parent3116d4f0fef9ac1e39a434dc6521109f1e0cffbf (diff)
parent9b2a531781ed785dc28d20441ffdb8cc5619711b (diff)
Merge pull request #458 from ctiller/fix5
Correctly handle large headers in HPACK table
-rw-r--r--src/core/transport/chttp2/hpack_table.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/core/transport/chttp2/hpack_table.c b/src/core/transport/chttp2/hpack_table.c
index 1b944232d8..f5c10f934b 100644
--- a/src/core/transport/chttp2/hpack_table.c
+++ b/src/core/transport/chttp2/hpack_table.c
@@ -164,7 +164,21 @@ void grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
/* we can't add elements bigger than the max table size */
- assert(elem_bytes <= tbl->max_bytes);
+ if (elem_bytes > tbl->max_bytes) {
+ /* HPACK draft 10 section 4.4 states:
+ * If the size of the new entry is less than or equal to the maximum
+ * size, that entry is added to the table. It is not an error to
+ * attempt to add an entry that is larger than the maximum size; an
+ * attempt to add an entry larger than the entire table causes
+ * the table
+ * to be emptied of all existing entries, and results in an
+ * empty table.
+ */
+ while (tbl->num_ents) {
+ evict1(tbl);
+ }
+ return;
+ }
/* evict entries to ensure no overflow */
while (elem_bytes > tbl->max_bytes - tbl->mem_used) {