Skip to content

Commit

Permalink
Properly handle SETTINGS_HEADER_TABLE_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
nwgh committed Sep 15, 2016
1 parent b7071e1 commit 0ae85eb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/protocol/compressor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1090,18 +1090,37 @@ 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
// instance. This means that from now on, the advantages of streaming header encoding are lost,
// 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 = [];

Expand Down

0 comments on commit 0ae85eb

Please sign in to comment.