{"id":16834568,"url":"https://github.com/gobwas/httphead","last_synced_at":"2025-04-04T19:14:24.908Z","repository":{"id":57480018,"uuid":"83088296","full_name":"gobwas/httphead","owner":"gobwas","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-08T10:25:42.000Z","size":46,"stargazers_count":85,"open_issues_count":0,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-29T19:58:24.388Z","etag":null,"topics":["headers","http","parsing","rfc-2616"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gobwas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-24T22:29:48.000Z","updated_at":"2024-05-31T15:11:31.000Z","dependencies_parsed_at":"2022-09-26T17:41:34.140Z","dependency_job_id":null,"html_url":"https://github.com/gobwas/httphead","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhttphead","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhttphead/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhttphead/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobwas%2Fhttphead/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gobwas","download_url":"https://codeload.github.com/gobwas/httphead/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["headers","http","parsing","rfc-2616"],"created_at":"2024-10-13T12:06:28.846Z","updated_at":"2025-04-04T19:14:24.867Z","avatar_url":"https://github.com/gobwas.png","language":"Go","readme":"# httphead.[go](https://golang.org)\n\n[![GoDoc][godoc-image]][godoc-url] \n\n\u003e Tiny HTTP header value parsing library in go.\n\n## Overview\n\nThis library contains low-level functions for scanning HTTP RFC2616 compatible header value grammars.\n\n## Install\n\n```shell\n    go get github.com/gobwas/httphead\n```\n\n## Example\n\nThe example below shows how multiple-choise HTTP header value could be parsed with this library:\n\n```go\n\toptions, ok := httphead.ParseOptions([]byte(`foo;bar=1,baz`), nil)\n\tfmt.Println(options, ok)\n\t// Output: [{foo map[bar:1]} {baz map[]}] true\n```\n\nThe low-level example below shows how to optimize keys skipping and selection\nof some key:\n\n```go\n\t// The right part of full header line like:\n\t// X-My-Header: key;foo=bar;baz,key;baz\n\theader := []byte(`foo;a=0,foo;a=1,foo;a=2,foo;a=3`)\n\n\t// We want to search key \"foo\" with an \"a\" parameter that equal to \"2\".\n\tvar (\n\t\tfoo = []byte(`foo`)\n\t\ta   = []byte(`a`)\n\t\tv   = []byte(`2`)\n\t)\n\tvar found bool\n\thttphead.ScanOptions(header, func(i int, key, param, value []byte) Control {\n\t\tif !bytes.Equal(key, foo) {\n\t\t\treturn ControlSkip\n\t\t}\n\t\tif !bytes.Equal(param, a) {\n\t\t\tif bytes.Equal(value, v) {\n\t\t\t\t// Found it!\n\t\t\t\tfound = true\n\t\t\t\treturn ControlBreak\n\t\t\t}\n\t\t\treturn ControlSkip\n\t\t}\n\t\treturn ControlContinue\n\t})\n```\n\nFor more usage examples please see [docs][godoc-url] or package tests.\n\n[godoc-image]: https://godoc.org/github.com/gobwas/httphead?status.svg\n[godoc-url]: https://godoc.org/github.com/gobwas/httphead\n[travis-image]: https://travis-ci.org/gobwas/httphead.svg?branch=master\n[travis-url]: https://travis-ci.org/gobwas/httphead\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fhttphead","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobwas%2Fhttphead","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobwas%2Fhttphead/lists"}