MCPcopy Create free account
hub / github.com/WICG/webpackage / parseItem

Method parseItem

go/signedexchange/structuredheader/parser.go:199–218  ·  view source on GitHub ↗

https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-09#section-4.2.7

()

Source from the content-addressed store, hash-verified

197
198// https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-09#section-4.2.7
199func (p *parser) parseItem() (Item, error) {
200 if p.isEmpty() {
201 return nil, errors.New("structuredheader: item expected, got EOS")
202 }
203 c := p.input[0]
204 if c == '-' || isDigit(c) {
205 return p.parseNumber()
206 }
207 if c == '"' {
208 return p.parseString()
209 }
210 if c == '*' {
211 return p.parseByteSequence()
212 }
213 // TODO: Support Booleans.
214 if isAlpha(c) {
215 return p.parseToken()
216 }
217 return nil, fmt.Errorf("structuredheader: item expected, got '%c'", c)
218}
219
220// https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-09#section-4.2.8
221func (p *parser) parseNumber() (int64, error) {

Callers 3

TestParseItemFunction · 0.95
parseListOfListsMethod · 0.95

Calls 7

isEmptyMethod · 0.95
parseNumberMethod · 0.95
parseStringMethod · 0.95
parseByteSequenceMethod · 0.95
parseTokenMethod · 0.95
isDigitFunction · 0.85
isAlphaFunction · 0.85

Tested by 1

TestParseItemFunction · 0.76