Skip to content

Commit

Permalink
implement HeaderField.IsPseudo
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 10, 2019
1 parent 90c9691 commit 416d651
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
16 changes: 16 additions & 0 deletions header_field.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package qpack

// A HeaderField is a name-value pair. Both the name and value are
// treated as opaque sequences of octets.
type HeaderField struct {
Name string
Value string
}

// IsPseudo reports whether the header field is an HTTP3 pseudo header.
// That is, it reports whether it starts with a colon.
// It is not otherwise guaranteed to be a valid pseudo header field,
// though.
func (hf HeaderField) IsPseudo() bool {
return len(hf.Name) != 0 && hf.Name[0] == ':'
}
16 changes: 16 additions & 0 deletions header_field_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package qpack

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("Header Field", func() {
It("says if it is pseudo", func() {
Expect((HeaderField{Name: ":status"}).IsPseudo()).To(BeTrue())
Expect((HeaderField{Name: ":authority"}).IsPseudo()).To(BeTrue())
Expect((HeaderField{Name: ":foobar"}).IsPseudo()).To(BeTrue())
Expect((HeaderField{Name: "status"}).IsPseudo()).To(BeFalse())
Expect((HeaderField{Name: "foobar"}).IsPseudo()).To(BeFalse())
})
})
7 changes: 0 additions & 7 deletions static_table.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package qpack

// A HeaderField is a name-value pair. Both the name and value are
// treated as opaque sequences of octets.
type HeaderField struct {
Name string
Value string
}

var staticTableEntries = [...]HeaderField{
{Name: ":authority"},
{Name: ":path", Value: "/"},
Expand Down

0 comments on commit 416d651

Please sign in to comment.