
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@httpland/http-compress
Advanced tools
Compress HTTP response, supported Web standard compression methods
Compress HTTP response, supported Web standard compression methods
gzip, deflate and brotli is built-in.
The package supports multiple platforms.
https://deno.land/x/http_compress/mod.ts@httpland/http-compressTakes a handler and returns a handler with the response body compressed.
import { withCompress } from "https://deno.land/x/http_compress@$VERSION/mod.ts";
function handler(req: Request): Response {
return new Response("Huge content");
}
Deno.serve(withCompress(handler));
You have complete control over what is compressed.
Various factors such as content length, media type, CPU usage, etc. can be used as filtering criteria.
The filter field is a function that takes a boolean. If true, responses
containing that content will be compressed.
By default, If the content is more than 10kb and its media type is compressible, compress it.
The following example compresses when the content is more than 10kb, the media
type is text/html, and request method is GET.
import { withCompress } from "https://deno.land/x/http_compress@$VERSION/mod.ts";
const handler = withCompress(() => new Response("Huge content"), {
filter: (content, { request, response }) => {
return 1024_0 < content.byteLength && // 10kb
request.method === "GET" &&
response.headers.get("Content-Type") === "text/html";
},
});
Deno.serve(handler);
Whether the media type is compressible or not.
This refers to the mime-db.
import { isCompressible } from "https://deno.land/x/http_compress@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std@$VERSION/testing/asserts.ts";
assertEquals(isCompressible("text/html"), true);
assertEquals(isCompressible("image/png"), false);
Supported compression method is follow:
Create a new Response object with the compressed value of the response body.
No destructive changes are made to the original Response object.
For the Response header, the following fields may be added:
Handler - It is a function that takes a Request object as its first argument
and returns a Response or Promise<Response> object.
type Handler = (request: Request) => Promise<Response> | Response;
Copyright © 2022-present httpland.
Released under the MIT license
FAQs
Compress HTTP response, supported Web standard compression methods
We found that @httpland/http-compress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.