Skip to main content

@std/http@0.215.0

latest
Works with
It is unknown whether this package works with Node.js, Deno, Browsers, Cloudflare Workers, Bun
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Provides user-friendly serve on top of Deno's native HTTP server and other utilities for creating HTTP servers and clients.

File Server

A small program for serving local files over HTTP.

deno run --allow-net --allow-read https://deno.land/std/http/file_server.ts
> HTTP server listening on http://localhost:4507/

HTTP Status Code and Status Text

Helper for processing status code and status text.

HTTP errors

Provides error classes for each HTTP error status code as well as utility functions for handling HTTP errors in a structured way.

Methods

Provides helper functions and types to work with HTTP method strings safely.

Negotiation

A set of functions which can be used to negotiate content types, encodings and languages when responding to requests.

Note: some libraries include accept charset functionality by analyzing the Accept-Charset header. This is a legacy header that clients omit and servers should ignore therefore is not provided.

An alternative to cookie.ts is cookie_map.ts which provides CookieMap, SecureCookieMap, and mergeHeaders to manage request and response cookies with the familiar Map interface.

User agent handling

The UserAgent class provides user agent string parsing, allowing a user agent flag to be semantically understood.

For example to integrate the user agent provided in the header User-Agent in an http request would look like this:

import { UserAgent } from "@std/http/user_agent";

Deno.serve((req) => {
  const userAgent = new UserAgent(req.headers.get("user-agent") ?? "");
  return new Response(`Hello, ${userAgent.browser.name}
    on ${userAgent.os.name} ${userAgent.os.version}!`);
});

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/http

Import symbol

import * as http from "@std/http";
or

Import directly with a jsr specifier

import * as http from "jsr:@std/http";