From 0ae85eb4e90c990f1047d26dde1fa1305a780c4e Mon Sep 17 00:00:00 2001 From: Nicholas Hurley Date: Thu, 15 Sep 2016 15:04:49 -0700 Subject: [PATCH] Properly handle SETTINGS_HEADER_TABLE_SIZE --- lib/protocol/compressor.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/protocol/compressor.js b/lib/protocol/compressor.js index f1d1795..3923a91 100644 --- a/lib/protocol/compressor.js +++ b/lib/protocol/compressor.js @@ -1090,11 +1090,20 @@ function Compressor(log, type) { assert((type === 'REQUEST') || (type === 'RESPONSE')); this._table = new HeaderTable(this._log); + + this.tableSizeChangePending = false; + this.lowestTableSizePending = 0; + this.tableSizeSetting = DEFAULT_HEADER_TABLE_LIMIT; } // Changing the header table size Compressor.prototype.setTableSizeLimit = function setTableSizeLimit(size) { this._table.setSizeLimit(size); + if (!this.tableSizeChangePending || size < this.lowestTableSizePending) { + this.lowestTableSizePending = size; + } + this.tableSizeSetting = size; + this.tableSizeChangePending = true; }; // `compress` takes a header set, and compresses it using a new `HeaderSetCompressor` stream @@ -1102,6 +1111,16 @@ Compressor.prototype.setTableSizeLimit = function setTableSizeLimit(size) { // but the API becomes simpler. Compressor.prototype.compress = function compress(headers) { var compressor = new HeaderSetCompressor(this._log, this._table); + + if (this.tableSizeChangePending) { + if (this.lowestTableSizePending < this.tableSizeSetting) { + compressor.send({contextUpdate: true, newMaxSize: this.lowestTableSizePending, + name: "", value: "", index: 0}); + } + compressor.send({contextUpdate: true, newMaxSize: this.tableSizeSetting, + name: "", value: "", index: 0}); + this.tableSizeChangePending = false; + } var colonHeaders = []; var nonColonHeaders = [];