https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-09#section-4.2.8
()
| 219 | |
| 220 | // https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-09#section-4.2.8 |
| 221 | func (p *parser) parseNumber() (int64, error) { |
| 222 | if p.isEmpty() { |
| 223 | return 0, errors.New("structuredheader: number expected, got EOS") |
| 224 | } |
| 225 | if p.input[0] != '-' && !isDigit(p.input[0]) { |
| 226 | return 0, fmt.Errorf("structuredheader: number expected, got '%c'", p.input[0]) |
| 227 | } |
| 228 | // TODO: Support Floats. |
| 229 | i := 1 |
| 230 | for i < len(p.input) && isDigit(p.input[i]) { |
| 231 | i++ |
| 232 | } |
| 233 | s := p.getString(i) |
| 234 | n, err := strconv.ParseInt(s, 10, 64) |
| 235 | if err != nil { |
| 236 | return 0, fmt.Errorf("structuredheader: couldn't parse %q as number: %v", s, err) |
| 237 | } |
| 238 | return n, nil |
| 239 | } |
| 240 | |
| 241 | // https://tools.ietf.org/html/draft-ietf-httpbis-header-structure-09#section-4.2.9 |
| 242 | func (p *parser) parseString() (string, error) { |