{"id":19738265,"url":"https://github.com/httptoolkit/http-encoding","last_synced_at":"2025-10-06T16:32:23.605Z","repository":{"id":57268131,"uuid":"368238989","full_name":"httptoolkit/http-encoding","owner":"httptoolkit","description":"Everything you need to handle HTTP message body content-encoding","archived":false,"fork":false,"pushed_at":"2024-07-29T12:44:43.000Z","size":86,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-15T04:48:44.476Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/httptoolkit.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-17T15:41:18.000Z","updated_at":"2024-12-07T00:44:46.000Z","dependencies_parsed_at":"2024-06-18T19:19:15.351Z","dependency_job_id":"b2a259d7-6e2d-46d7-9263-a4c15ed25fdb","html_url":"https://github.com/httptoolkit/http-encoding","commit_stats":{"total_commits":38,"total_committers":1,"mean_commits":38.0,"dds":0.0,"last_synced_commit":"0d635e0123162150a62bfcab2c369224b8e38577"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttp-encoding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttp-encoding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttp-encoding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fhttp-encoding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/httptoolkit","download_url":"https://codeload.github.com/httptoolkit/http-encoding/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235534957,"owners_count":19005581,"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-12T01:13:42.751Z","updated_at":"2025-10-06T16:32:23.600Z","avatar_url":"https://github.com/httptoolkit.png","language":"TypeScript","readme":"# http-encoding [![Build Status](https://github.com/httptoolkit/http-encoding/workflows/CI/badge.svg)](https://github.com/httptoolkit/http-encoding/actions) [![Available on NPM](https://img.shields.io/npm/v/http-encoding.svg)](https://npmjs.com/package/http-encoding)\n\n\u003e _Part of [HTTP Toolkit](https://httptoolkit.com): powerful tools for building, testing \u0026 debugging HTTP(S)_\n\n**Everything you need to handle HTTP message body content-encoding**\n\nThis package includes methods to decode \u0026 encode all commonly used HTTP content encodings, in a consistent format, usable in a wide range of Node.js versions and browsers.\n\nThe supported codecs are:\n\n* Gzip\n* Raw deflate (with or without a zlib wrapper)\n* Brotli\n* Zstandard\n* Base64\n\nAll encoding names are case-insensitive (although lowercase is generally standard). The 'identity', 'amz-1.0', 'none', 'text', 'binary', 'utf8' and 'utf-8' encodings are all supported as no-op encodings, passed through with no en/decoding at all. Only 'identity' is standard, but the others are all in common use regardless.\n\nFound a codec used in real-world HTTP that isn't supported? Open an issue!\n\n## API\n\nThe library includes two general methods:\n\n### `decodeBuffer(body, encoding)`\n\nTakes an encoded body buffer and encoding (in the format of a standard HTTP [content-encoding header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding)) and returns a promise for a decoded buffer, using the zero to many buffers specified in the header.\n\nThe input buffer can be any Uint8Array including a Node Buffer (a subclass of Uint8Array). A node-compatible buffer is always returned.\n\nIf any encoding is unrecognized or unavailable then this method will throw an exception.\n\nA `decodeBufferSync` method is also available for some use cases, but not recommended, as it's less performant and cannot support some encodings (Brotli or Zstandard).\n\n### `encodeBuffer(body, encoding, { level })`\n\nTakes a raw body buffer and a single encoding (a valid HTTP [content-encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) name) and returns a promise for an encoded buffer, using the zero to many buffers specified in the header.\n\nThe input buffer can be any Uint8Array (including a Node Buffer, which is a Uint8Array subclass) or an ArrayBuffer. A node-compatible buffer is always returned.\n\nIf any encoding is unrecognized or unavailable then this method will throw an exception.\n\n## Per-codec methods\n\nThis library also exports consistent async methods to compress and decompress each of the codecs directly:\n\n* `gzip`\n* `gunzip`\n* `deflate`\n* `inflate`\n* `inflateRaw`\n* `brotliCompress`\n* `brotliDecompress`\n* `zstdCompress`\n* `zstdDecompress`\n* `encodeBase64`\n* `decodeBase64`\n\nEach method accepts a buffer and returns a promise for a buffer.\n\n## Browser usage\n\nTo use this in a browser, you'll need to use a bundler (e.g. Webpack) that can include standard Node.js polyfill packages, you may need to install those polyfill packages, and your bundler needs to support bundling WebAssembly (e.g. Webpack v4+).\n\nIn Webpack v4 this should all work automatically. In Webpack v5 this will require explicit dependencies and configuration. See this package's own [test webpack config](./karma.conf.js#L14-L44) and [dev dependencies](./package.json) for a working example.\n\nBrotli and Zstandard are only supported in runtime environments that support WebAssembly. All WebAssembly packages are loaded on-demand and only when native methods (e.g. Node's `zlib.brotli*`) are not available.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fhttp-encoding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttptoolkit%2Fhttp-encoding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fhttp-encoding/lists"}