summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/net/http2/hpack
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/net/http2/hpack')
-rw-r--r--vendor/golang.org/x/net/http2/hpack/tables.go4
-rw-r--r--vendor/golang.org/x/net/http2/hpack/tables_test.go26
2 files changed, 28 insertions, 2 deletions
diff --git a/vendor/golang.org/x/net/http2/hpack/tables.go b/vendor/golang.org/x/net/http2/hpack/tables.go
index 870159244..31bd5a553 100644
--- a/vendor/golang.org/x/net/http2/hpack/tables.go
+++ b/vendor/golang.org/x/net/http2/hpack/tables.go
@@ -69,10 +69,10 @@ func (t *headerFieldTable) evictOldest(n int) {
f := t.ents[k]
id := t.evictCount + uint64(k) + 1
if t.byName[f.Name] == id {
- t.byName[f.Name] = 0
+ delete(t.byName, f.Name)
}
if p := (pairNameValue{f.Name, f.Value}); t.byNameValue[p] == id {
- t.byNameValue[p] = 0
+ delete(t.byNameValue, p)
}
}
copy(t.ents, t.ents[n:])
diff --git a/vendor/golang.org/x/net/http2/hpack/tables_test.go b/vendor/golang.org/x/net/http2/hpack/tables_test.go
index 7f40d9a42..d963f3635 100644
--- a/vendor/golang.org/x/net/http2/hpack/tables_test.go
+++ b/vendor/golang.org/x/net/http2/hpack/tables_test.go
@@ -89,6 +89,32 @@ func TestHeaderFieldTable(t *testing.T) {
}
}
+func TestHeaderFieldTable_LookupMapEviction(t *testing.T) {
+ table := &headerFieldTable{}
+ table.init()
+ table.addEntry(pair("key1", "value1-1"))
+ table.addEntry(pair("key2", "value2-1"))
+ table.addEntry(pair("key1", "value1-2"))
+ table.addEntry(pair("key3", "value3-1"))
+ table.addEntry(pair("key4", "value4-1"))
+ table.addEntry(pair("key2", "value2-2"))
+
+ // evict all pairs
+ table.evictOldest(table.len())
+
+ if l := table.len(); l > 0 {
+ t.Errorf("table.len() = %d, want 0", l)
+ }
+
+ if l := len(table.byName); l > 0 {
+ t.Errorf("len(table.byName) = %d, want 0", l)
+ }
+
+ if l := len(table.byNameValue); l > 0 {
+ t.Errorf("len(table.byNameValue) = %d, want 0", l)
+ }
+}
+
func TestStaticTable(t *testing.T) {
fromSpec := `
+-------+-----------------------------+---------------+