Skip to content

Commit 416d651

Browse files
implement HeaderField.IsPseudo
1 parent 90c9691 commit 416d651

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

header_field.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package qpack
2+
3+
// A HeaderField is a name-value pair. Both the name and value are
4+
// treated as opaque sequences of octets.
5+
type HeaderField struct {
6+
Name string
7+
Value string
8+
}
9+
10+
// IsPseudo reports whether the header field is an HTTP3 pseudo header.
11+
// That is, it reports whether it starts with a colon.
12+
// It is not otherwise guaranteed to be a valid pseudo header field,
13+
// though.
14+
func (hf HeaderField) IsPseudo() bool {
15+
return len(hf.Name) != 0 && hf.Name[0] == ':'
16+
}

header_field_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package qpack
2+
3+
import (
4+
. "github.com/onsi/ginkgo"
5+
. "github.com/onsi/gomega"
6+
)
7+
8+
var _ = Describe("Header Field", func() {
9+
It("says if it is pseudo", func() {
10+
Expect((HeaderField{Name: ":status"}).IsPseudo()).To(BeTrue())
11+
Expect((HeaderField{Name: ":authority"}).IsPseudo()).To(BeTrue())
12+
Expect((HeaderField{Name: ":foobar"}).IsPseudo()).To(BeTrue())
13+
Expect((HeaderField{Name: "status"}).IsPseudo()).To(BeFalse())
14+
Expect((HeaderField{Name: "foobar"}).IsPseudo()).To(BeFalse())
15+
})
16+
})

static_table.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package qpack
22

3-
// A HeaderField is a name-value pair. Both the name and value are
4-
// treated as opaque sequences of octets.
5-
type HeaderField struct {
6-
Name string
7-
Value string
8-
}
9-
103
var staticTableEntries = [...]HeaderField{
114
{Name: ":authority"},
125
{Name: ":path", Value: "/"},

0 commit comments

Comments
 (0)