MCPcopy Create free account
hub / github.com/gobwas/httphead

github.com/gobwas/httphead @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
126 symbols 300 edges 12 files ⚖ MIT 67 documented · 53% 61 cross-repo links updated 5y agov0.1.0 · 2020-12-08★ 85

Browse by type

Functions 107 Types & classes 19
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

httphead.go

GoDoc

Tiny HTTP header value parsing library in go.

Overview

This library contains low-level functions for scanning HTTP RFC2616 compatible header value grammars.

Install

    go get github.com/gobwas/httphead

Example

The example below shows how multiple-choise HTTP header value could be parsed with this library:

    options, ok := httphead.ParseOptions([]byte(`foo;bar=1,baz`), nil)
    fmt.Println(options, ok)
    // Output: [{foo map[bar:1]} {baz map[]}] true

The low-level example below shows how to optimize keys skipping and selection of some key:

    // The right part of full header line like:
    // X-My-Header: key;foo=bar;baz,key;baz
    header := []byte(`foo;a=0,foo;a=1,foo;a=2,foo;a=3`)

    // We want to search key "foo" with an "a" parameter that equal to "2".
    var (
        foo = []byte(`foo`)
        a   = []byte(`a`)
        v   = []byte(`2`)
    )
    var found bool
    httphead.ScanOptions(header, func(i int, key, param, value []byte) Control {
        if !bytes.Equal(key, foo) {
            return ControlSkip
        }
        if !bytes.Equal(param, a) {
            if bytes.Equal(value, v) {
                // Found it!
                found = true
                return ControlBreak
            }
            return ControlSkip
        }
        return ControlContinue
    })

For more usage examples please see docs or package tests.

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 64
Method 43
Struct 14
TypeAlias 5

Languages

Go100%

Modules by API surface

lexer.go24 symbols
option.go22 symbols
head.go16 symbols
httphead_test.go15 symbols
httphead.go13 symbols
cookie.go8 symbols
octet.go7 symbols
lexer_test.go6 symbols
writer.go5 symbols
head_test.go4 symbols
cookie_test.go4 symbols
writer_test.go2 symbols

For agents

$ claude mcp add httphead \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page