# @288-toolkit/http

> A collection of functions to work with http.

Latest version **4.5.0** (published 2026-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @288-toolkit/http
pnpm add @288-toolkit/http
yarn add @288-toolkit/http
bun add @288-toolkit/http
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.5.0 |
| Published | 2026-07-16 |
| First published | 2024-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 16.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | DeuxHuitHuit |
| Maintainers | nitriques |

## Links

- npm: https://www.npmjs.com/package/@288-toolkit/http
- Repository: https://github.com/DeuxHuitHuit/288-toolkit
- Homepage: https://github.com/DeuxHuitHuit/288-toolkit/blob/main/packages/http/README.md
- Issues: https://github.com/DeuxHuitHuit/288-toolkit/issues
- npm.io page: https://npm.io/package/@288-toolkit/http

## Dependencies (1)

- [@288-toolkit/types](https://npm.io/package/@288-toolkit/types.md) 3.1.0

## Recent versions

- 4.5.0 (latest) — 2026-07-16
- 4.4.1 — 2025-09-23
- 4.4.0 — 2025-04-30
- 4.3.0 — 2025-03-17
- 4.2.0 — 2025-03-13
- 4.1.1 — 2024-05-16
- 4.1.0 — 2024-05-02
- 4.0.0 — 2024-05-01
- 3.0.0 — 2024-04-30
- 1.1.2 — 2024-04-25
- 1.1.1 — 2024-04-24
- 1.1.0 — 2024-04-11
- 1.0.1 — 2024-04-11
- 1.0.0 — 2024-04-11

## README

# Http

A collection of functions to work with http.

## `cacheHeaders`

Generates a `cache-control` header object from the provided options.

If `enabled: false`, the `cache-control` header will be
`'private, no-cache, noindex, max-age=0, must-revalidate'`.

```ts
type CacheHeadersOptions = {
	// Disables the cache entirely
	enabled?: boolean;
	// All cache-control directives
	maxAge?: number;
	sMaxAge?: number;
	staleWhileRevalidate?: number;
	staleIfError?: number;
	private?: boolean;
	public?: boolean;
	noCache?: boolean;
	noStore?: boolean;
	noTransform?: boolean;
	immutable?: boolean;
	mustRevalidate?: boolean;
	proxyRevalidate?: boolean;
	mustUnderstand?: boolean;
};

const cacheControl = cacheHeaders({
	// ...
});

return new Response('', {
	headers: cacheControl
});
```

## `fetchTimeout`

Fetch with a timeout. Defaults to 20 seconds.

```ts
// 5 second timeout
const response = await fetchTimeout(url, { ... }, 5000);
```

## `isRedirectResponse`

Returns `true` if the response is a redirect response.

```ts
const isRedirectResponse: (response: Response) => boolean;
```

## `isWithoutBody`

Returns `true` if the request should not have a body.

```ts
const isWithoutBody: (request: Request) => boolean;
```

## `getLangFromRequest` (deprecated)

Get the language from the request.

```ts
const getLangFromRequest = <Language extends string>(
	request: Request,
	{ supportedLanguages: Language[]; defaultLanguage: Language }
) => Language;
```

## `parseAcceptLanguage`

Given a string of the form "en,fr;q=0.9,de;q=0.8", returns an array of `AcceptLanguageEntry` ordered
by priority. This is mostly used to parse the `'Accept-Language'` header.

```ts
type AcceptLanguageEntry = {
	lang: string;
	priority: number;
};

const parseAcceptLanguage = (acceptLanguage: string): Maybe<AcceptLanguageEntry[]>
```

## `acceptedLanguage`

Get the accepted language from the request.

```ts
const language = acceptedLanguage(request, {
	supportedLanguages: ['en', 'fr'],
	defaultLanguage: 'en'
});
```

## `getVercelIpHeaders`

Get Vercel headers from a request.

```ts
const getVercelIpHeaders: (request: Request) => {
	continent: Maybe<string>;
	country: Maybe<string>;
	region: Maybe<string>;
	city: Maybe<string>;
	latitude: Maybe<string>;
	longitude: Maybe<string>;
	timezone: Maybe<string>;
	ip: Maybe<string>;
};
```

---
_Source: https://npm.io/package/@288-toolkit/http · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
