
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@httpland/http-conditional-requests
Advanced tools
HTTP Conditional Requests middleware for Fetch API
HTTP Conditional Requests middleware for Fetch API.
Middleware for HTTP Conditional Requests.
It conditionally processes a HTTP request based on a precondition.
It compliant with RFC 9110, 13. Conditional Requests.
For a definition of Universal HTTP middleware, see the http-middleware project.
Middleware factory is exported by default.
To evaluate precondition, you need to provide a function to retrieve the selected representation.
The following example evaluates the If-None-Match precondition and controls
the handler.
import conditionalRequests from "https://deno.land/x/http_conditional_requests@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
import { assertSpyCalls, spy } from "https://deno.land/std/testing/mock.ts";
const selectedRepresentation = new Response("<body>", {
headers: { etag: "<etag>" },
});
const selectRepresentation = spy(() => selectedRepresentation);
const middleware = conditionalRequests(selectRepresentation);
const conditionalRequest = new Request("<uri>", {
headers: { "if-none-match": "<etag>" },
});
const handler = spy(() => selectedRepresentation);
const response = await middleware(conditionalRequest, handler);
assertSpyCalls(handler, 0);
assertSpyCalls(selectRepresentation, 1);
assertEquals(response.status, 304);
RFC 9110, 13.1. Preconditions compliant and supports the following precondition:
If multiple precondition headers are present, precondition is processed according to precedence.
Middleware will effect following:
Middleware will execute only if the following conditions are met:
If-Match
ETag header existIf-None-Match
ETag header existIf-Modified-Since
Last-Modified header existIf-Unmodified-Since
Last-Modified header existCopyright © 2023-present httpland.
Released under the MIT license
FAQs
HTTP Conditional Requests middleware for Fetch API
We found that @httpland/http-conditional-requests 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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.