{"id":19884298,"url":"https://github.com/techempower/openhttpheaders","last_synced_at":"2025-07-16T05:06:31.268Z","repository":{"id":65507963,"uuid":"554466951","full_name":"TechEmpower/OpenHttpHeaders","owner":"TechEmpower","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-24T22:47:36.000Z","size":96,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T00:51:25.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TechEmpower.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":"2022-10-19T21:32:54.000Z","updated_at":"2024-06-30T22:39:10.000Z","dependencies_parsed_at":"2023-01-26T16:15:16.250Z","dependency_job_id":null,"html_url":"https://github.com/TechEmpower/OpenHttpHeaders","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/TechEmpower/OpenHttpHeaders","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechEmpower%2FOpenHttpHeaders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechEmpower%2FOpenHttpHeaders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechEmpower%2FOpenHttpHeaders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechEmpower%2FOpenHttpHeaders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TechEmpower","download_url":"https://codeload.github.com/TechEmpower/OpenHttpHeaders/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechEmpower%2FOpenHttpHeaders/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265483270,"owners_count":23774176,"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":[],"created_at":"2024-11-12T17:26:09.193Z","updated_at":"2025-07-16T05:06:31.031Z","avatar_url":"https://github.com/TechEmpower.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenHTTPHeaders\n\nThis library provides first-party support to Kotlin and Java for HTTP header \nparsing and creation. It is not tied to any particular framework, and provides \nfirst-party support to Kotlin, with second-party support for Java only in that \nit is dependent on the Kotlin standard library (stdlib) but otherwise fully \nsupports Java. There are no other dependencies.\n\n### Sample Code\n\nTo create an Accept header in Kotlin:\n\n```kotlin\nacceptHeader {\n  mediaType(type = \"text\", subtype = \"xml\") {\n    parameters(\n      \"charset\" to \"utf-8\"\n    )\n    quality = 0.5\n  }\n  mediaType(type = \"text\", subtype = \"html\")\n}.toHeaderString()\n// This produces \"text/xml;charset=utf-8;q=0.5,text/html\"\n```\n\nTo do the same in Java:\n\n```jshelllanguage\nAcceptHeader.builder()\n    .addMediaType(\n        MediaType.builder(\"text\", \"xml\")\n            .addParameter(\"charset\", \"utf-8\")\n            .quality(0.5)\n            .build()\n    )\n    .addMediaType(\n        MediaType.builder(\"text\", \"html\").build()\n    )\n    .build()\n    .toHeaderString()\n\n// or\n\nAcceptHeader.of(\n    MediaType.of(\"text\", \"xml\")\n        .addParameter(\"charset\", \"utf-8\")\n        .quality(0.5)\n).toHeaderString()\n\n// These both produce \"text/xml;charset=utf-8;q=0.5,text/html\"\n```\n\nTo parse an Accept header, in both languages, call:\n\n```kotlin\nAcceptHeader.parse(\"text/xml;charset=utf-8;q=0.5,text/html\")\n// This produces the objects described above, specifically:\n// AcceptHeader(\n//   mediaTypes = [\n//     MediaType(\n//       type = \"text\",\n//       subtype = \"xml\",\n//       parameters = {\n//         \"charset\": \"utf-8\",\n//         \"q\": \"0.5\"\n//       },\n//       quality = 0.5\n//     ),\n//     MediaType(\n//       type = \"text\",\n//       subtype = \"html\"\n//     )\n//   ]\n// )\n```\n\n## Contributing\n\n### Build and Test\n\nAfter checking out this project, to build, run:\n\n```shell\n./gradlew build\n```\n\nTo run all tests, run:\n\n```shell\n./gradlew cleanTest test\n```\n\nNote: `cleanTest` is necessary because Gradle may otherwise detect that no\nchanges to the tested code have occurred and skip running tests. The above\nguarantees that the tests are run when requested. \n\n### Publish\n\nAdd to `~/.gradle/gradle.properties` (or create if it doesn't already exist):\n\n```properties\nsigning.keyId=\u003credacted\u003e\n# The following will likely be `~/.gnupg/pubring.kbx` or `~/.gnupg/secring.gpg`\n# depending on the file present, but it must be written out as a full path (not\n# using ~)\nsigning.secretKeyRingFile=\u003crequired\u003e\nsigning.gnupg.keyName=\u003credacted\u003e\nsigning.gnupg.passphrase=\u003credacted\u003e\nopenhttpheadersUsername=\u003credacted\u003e\nopenhttpheadersPassword=\u003credacted\u003e\n```\n\nNote: `signing.keyId` may not be necessary. Should be checked later.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechempower%2Fopenhttpheaders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechempower%2Fopenhttpheaders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechempower%2Fopenhttpheaders/lists"}