{"id":18603596,"url":"https://github.com/cogini/http_structured_field","last_synced_at":"2025-05-16T18:32:45.853Z","repository":{"id":57505861,"uuid":"340540634","full_name":"cogini/http_structured_field","owner":"cogini","description":"Elixir library to parse HTTP Structured Fields (RFC 8941)","archived":false,"fork":false,"pushed_at":"2023-10-24T02:41:34.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-04-24T20:03:59.913Z","etag":null,"topics":["elixir","http","rfc8941"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cogini.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-20T02:19:12.000Z","updated_at":"2023-10-24T02:41:37.000Z","dependencies_parsed_at":"2024-11-07T02:14:53.876Z","dependency_job_id":"f62977f3-6ed6-4cbe-b9ea-2c98e025a47e","html_url":"https://github.com/cogini/http_structured_field","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogini%2Fhttp_structured_field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogini%2Fhttp_structured_field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogini%2Fhttp_structured_field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cogini%2Fhttp_structured_field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cogini","download_url":"https://codeload.github.com/cogini/http_structured_field/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239394671,"owners_count":19631117,"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":["elixir","http","rfc8941"],"created_at":"2024-11-07T02:14:52.035Z","updated_at":"2025-05-16T18:32:44.294Z","avatar_url":"https://github.com/cogini.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"![test workflow](https://github.com/cogini/http_structured_field/actions/workflows/test.yml/badge.svg)\n[![Module Version](https://img.shields.io/hexpm/v/http_structured_field.svg)](https://hex.pm/packages/http_structured_field)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/http_structured_field)\n[![Total Download](https://img.shields.io/hexpm/dt/http_structured_field.svg)](https://hex.pm/packages/http_structured_field)\n[![License](https://img.shields.io/hexpm/l/http_structured_field.svg)](https://github.com/cogini/http_structured_field/blob/master/LICENSE.md)\n[![Last Updated](https://img.shields.io/github/last-commit/cogini/http_structured_field/main)](https://github.com/cogini/http_structured_field/commits/main)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)\n\n# http_structured_field\n\nElixir library to parse and generate RFC 8941 Structured Field Values for HTTP.\n\nHTTP headers often need to carry complex structures such as lists of values.\n[RFC 8941](https://tools.ietf.org/html/rfc8941) specifies a standard format\nfor these fields independent of the RFCs that define the headers.\n\nFollowing are some headers that use the format:\n\n* Permissions-Policy\n* Document-Policy\n* Reporting-Endpoints\n* BFCache-Opt-In\n* Accept-CH\n* Critical-CH\n* Supports-Loading-Mode\n* Signed-Headers\n* Sec-Redemption-Record\n* Sec-Signature\n\n## Usage\n\n```elixir\niex\u003e HttpStructuredField.parse(\"42\")\n{:ok, {:integer, 42}}\n\niex\u003e HttpStructuredField.parse(\"4.5\")\n{:ok, {:decimal, 4.5}}\n\niex\u003e HttpStructuredField.parse(\"?1\")\n{:ok, {:boolean, true}}\n\niex\u003e HttpStructuredField.parse(~S(\"hello world\"))\n{:ok, {:string, \"hello world\"}}\n\niex\u003e HttpStructuredField.parse(\"foo123/456\")\n{:ok, {:token, \"foo123/456\"}}\n\niex\u003e HttpStructuredField.parse(\":cHJldGVuZCB0aGlzIGlzIGJpbmFyeSBjb250ZW50Lg==:\")\n{:ok, {:binary, \"pretend this is binary content.\"}}\n\niex\u003e HttpStructuredField.parse(\"1; abc; b=?0\")\n{:ok, {:integer, 1, [{\"abc\", {:boolean, true}}, {\"b\", {:boolean, false}}]}}\n\niex\u003e HttpStructuredField.parse(\"foo, bar\")\n{:ok, [{:token, \"foo\"}, {:token, \"bar\"}]}\n\niex\u003e HttpStructuredField.parse(\"a=(1 2), b=3, c=4;aa=bb, d=(5 6);valid\", type: :dict)\n{:ok, [\n  {\"a\", {:inner_list, [integer: 1, integer: 2]}},\n  {\"b\", {:integer, 3}},\n  {\"c\", {:integer, 4, [{\"aa\", {:token, \"bb\"}}]}},\n  {\"d\", {:inner_list, [integer: 5, integer: 6], [{\"valid\", {:boolean, true}}]}}\n]}\n```\n\nThe parser uses [NimbleParsec](https://hex.pm/packages/nimble_parsec), so it's\nstrict, unlike, e.g., regular expressions.\n\nIt handles the funky syntax of parameters, nested lists, and dictionaries. You\ncan run it on any input and it will return a tagged tuple for a simple value or\nan Elixir list for a list of values. If there are parameters, then the tuple\nwill have three elements, with the third being a list. Inner List types are\ntagged tuples, as we need some place to put the parameters.\n\nParmeters and dictionary members are represented as lists of tuples where the\nname is the first tuple element.\n\nDictionary types are unfortunately incompatible with lists, so you have to tell\nthe parser what to expect by adding the `type: :dict` option.\n\n## Installation\n\nAdd `http_structured_field` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:http_structured_field, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\nThe docs can be found at [https://hexdocs.pm/http_structured_field](https://hexdocs.pm/http_structured_field).\n\nThis project uses the Contributor Covenant version 2.1. Check [CODE_OF_CONDUCT.md](/CODE_OF_CONDUCT.md) for more information.\n\n# Contacts\n\nI am `jakemorrison` on on the Elixir Slack and Discord, `reachfh` on Freenode\n`#elixir-lang` IRC channel. Happy to chat or help with your projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcogini%2Fhttp_structured_field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcogini%2Fhttp_structured_field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcogini%2Fhttp_structured_field/lists"}