HTTP Specification Reference Data

0.5.0 · active · verified Wed Apr 22

know-your-http-well is a JavaScript package that provides structured data for various HTTP specifications, including headers, media types, methods, relations, and status codes. It summarizes these elements and links directly to their respective RFCs and specifications. The current stable version is v0.6.0, with minor content updates driving recent releases. Its primary use case is to offer programmatic access to standardized HTTP information, such as converting status phrases to codes and vice-versa, making it useful for both server-side and client-side applications that need to interpret or generate HTTP messages correctly. The project serves as a reference data set, updated periodically with new RFCs and corrections, rather than offering complex runtime functionality or a rapid release cadence for API changes. Its key differentiator is providing this data in an easily consumable JSON and JavaScript format, directly referencing official specifications.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing the package using CommonJS and accessing HTTP status code utilities for both numerical codes and their corresponding phrases.

const httpWell = require('know-your-http-well');
const statusWell = httpWell.statusPhrasesToCodes;
const phraseWell = httpWell.statusCodesToPhrases;

// Example: Server-side usage
// In a hypothetical Express-like response handler:
// res.statusCode = statusWell.NOT_FOUND;
// console.log(`Set status to ${statusWell.NOT_FOUND}`);

// Example: Client-side or common logic
const responseStatusCode = 404; // Simulate a response status

if (responseStatusCode !== statusWell.OK) {
    // Log 'Request returned 404 Not Found'
    console.log('Request returned ' + responseStatusCode + ' ' + phraseWell[responseStatusCode]);
}
// Expected output: Request returned 404 Not Found

view raw JSON →