|
@@ -9,6 +9,8 @@
|
|
|
// See http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
|
|
// See http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08
|
|
|
package hpack
|
|
package hpack
|
|
|
|
|
|
|
|
|
|
+import "fmt"
|
|
|
|
|
+
|
|
|
// A HeaderField is a name-value pair. Both the name and value are
|
|
// A HeaderField is a name-value pair. Both the name and value are
|
|
|
// treated as opaque sequences of octets.
|
|
// treated as opaque sequences of octets.
|
|
|
type HeaderField struct {
|
|
type HeaderField struct {
|
|
@@ -18,5 +20,28 @@ type HeaderField struct {
|
|
|
// A Decoder is the decoding context for incremental processing of
|
|
// A Decoder is the decoding context for incremental processing of
|
|
|
// header blocks.
|
|
// header blocks.
|
|
|
type Decoder struct {
|
|
type Decoder struct {
|
|
|
- // ...
|
|
|
|
|
|
|
+ ht headerTable
|
|
|
|
|
+ refSet struct{} // TODO
|
|
|
|
|
+ Emit func(f HeaderField, sensitive bool)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+type headerTable []HeaderField
|
|
|
|
|
+
|
|
|
|
|
+func (s *headerTable) add(f HeaderField) {
|
|
|
|
|
+ *s = append(*s, f)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (s *headerTable) at(i int) HeaderField {
|
|
|
|
|
+ if i < 1 {
|
|
|
|
|
+ panic(fmt.Sprintf("header table index %d too small", i))
|
|
|
|
|
+ }
|
|
|
|
|
+ ht := *s
|
|
|
|
|
+ max := len(ht) + len(staticTable)
|
|
|
|
|
+ if i > max {
|
|
|
|
|
+ panic(fmt.Sprintf("header table index %d too large (max = %d)", i, max))
|
|
|
|
|
+ }
|
|
|
|
|
+ if i <= len(ht) {
|
|
|
|
|
+ return ht[i-1]
|
|
|
|
|
+ }
|
|
|
|
|
+ return staticTable[i-len(ht)-1]
|
|
|
}
|
|
}
|