pax_global_header00006660000000000000000000000064137742626170014531gustar00rootroot0000000000000052 comment=d6b7ddc474bd621bb9539b611e4da9dfd845d30e statuses-2.0.1/000077500000000000000000000000001377426261700134045ustar00rootroot00000000000000statuses-2.0.1/.eslintignore000066400000000000000000000000261377426261700161050ustar00rootroot00000000000000coverage node_modules statuses-2.0.1/.eslintrc.yml000066400000000000000000000000351377426261700160260ustar00rootroot00000000000000root: true extends: standard statuses-2.0.1/.github/000077500000000000000000000000001377426261700147445ustar00rootroot00000000000000statuses-2.0.1/.github/workflows/000077500000000000000000000000001377426261700170015ustar00rootroot00000000000000statuses-2.0.1/.github/workflows/ci.yml000066400000000000000000000105161377426261700201220ustar00rootroot00000000000000name: ci on: - pull_request - push jobs: test: runs-on: ubuntu-latest strategy: matrix: name: - Node.js 0.8 - Node.js 0.10 - Node.js 0.12 - io.js 1.x - io.js 2.x - io.js 3.x - Node.js 4.x - Node.js 5.x - Node.js 6.x - Node.js 7.x - Node.js 8.x - Node.js 9.x - Node.js 10.x - Node.js 11.x - Node.js 12.x - Node.js 13.x - Node.js 14.x - Node.js 15.x include: - name: Node.js 0.8 node-version: "0.8" npm-i: mocha@2.5.3 npm-rm: nyc - name: Node.js 0.10 node-version: "0.10" npm-i: mocha@3.5.3 nyc@10.3.2 - name: Node.js 0.12 node-version: "0.12" npm-i: mocha@3.5.3 nyc@10.3.2 - name: io.js 1.x node-version: "1.8" npm-i: mocha@3.5.3 nyc@10.3.2 - name: io.js 2.x node-version: "2.5" npm-i: mocha@3.5.3 nyc@10.3.2 - name: io.js 3.x node-version: "3.3" npm-i: mocha@3.5.3 nyc@10.3.2 - name: Node.js 4.x node-version: "4.9" npm-i: mocha@5.2.0 nyc@11.9.0 - name: Node.js 5.x node-version: "5.12" npm-i: mocha@5.2.0 nyc@11.9.0 - name: Node.js 6.x node-version: "6.17" npm-i: mocha@6.2.2 nyc@14.1.1 - name: Node.js 7.x node-version: "7.10" npm-i: mocha@6.2.2 nyc@14.1.1 - name: Node.js 8.x node-version: "8.17" npm-i: mocha@7.2.0 - name: Node.js 9.x node-version: "9.11" npm-i: mocha@7.2.0 - name: Node.js 10.x node-version: "10.23" - name: Node.js 11.x node-version: "11.15" - name: Node.js 12.x node-version: "12.20" - name: Node.js 13.x node-version: "13.14" - name: Node.js 14.x node-version: "14.15" - name: Node.js 15.x node-version: "15.5" steps: - uses: actions/checkout@v2 - name: Install Node.js ${{ matrix.node-version }} shell: bash -l {0} run: | nvm install --default ${{ matrix.node-version }} if [[ "${{ matrix.node-version }}" == 0.* ]]; then npm config set strict-ssl false fi dirname "$(npm which)" >> "$GITHUB_PATH" - name: Configure npm run: npm config set shrinkwrap false - name: Remove non-test npm modules run: npm rm --silent --save-dev csv-parse raw-body stream-to-array - name: Remove npm module(s) ${{ matrix.npm-rm }} run: npm rm --silent --save-dev ${{ matrix.npm-rm }} if: matrix.npm-rm != '' - name: Install npm module(s) ${{ matrix.npm-i }} run: npm install --save-dev ${{ matrix.npm-i }} if: matrix.npm-i != '' - name: Setup Node.js version-specific dependencies shell: bash run: | # eslint for linting # - remove on Node.js < 10 if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ grep -E '^eslint(-|$)' | \ sort -r | \ xargs -n1 npm rm --silent --save-dev fi - name: Install Node.js dependencies run: npm install - name: List environment id: list_env shell: bash run: | echo "node@$(node -v)" echo "npm@$(npm -v)" npm -s ls npm -s ls --depth=0 | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' - name: Run tests shell: bash run: | if npm -ps ls nyc | grep -q nyc; then npm run test-ci else npm test fi - name: Lint code if: steps.list_env.outputs.eslint != '' run: npm run lint - name: Collect code coverage uses: coverallsapp/github-action@master if: steps.list_env.outputs.nyc != '' with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.test_number }} parallel: true coverage: needs: test runs-on: ubuntu-latest steps: - name: Upload code coverage uses: coverallsapp/github-action@master with: github-token: ${{ secrets.github_token }} parallel-finished: true statuses-2.0.1/.gitignore000066400000000000000000000002651377426261700153770ustar00rootroot00000000000000# OS X .DS_Store* Icon? ._* # Windows Thumbs.db ehthumbs.db Desktop.ini # Linux .directory *~ # npm node_modules package-lock.json *.log *.gz # Coveralls .nyc_output coverage statuses-2.0.1/HISTORY.md000066400000000000000000000030121377426261700150630ustar00rootroot000000000000002.0.1 / 2021-01-03 ================== * Fix returning values from `Object.prototype` 2.0.0 / 2020-04-19 ================== * Drop support for Node.js 0.6 * Fix messaging casing of `418 I'm a Teapot` * Remove code 306 * Remove `status[code]` exports; use `status.message[code]` * Remove `status[msg]` exports; use `status.code[msg]` * Rename `425 Unordered Collection` to standard `425 Too Early` * Rename `STATUS_CODES` export to `message` * Return status message for `statuses(code)` when given code 1.5.0 / 2018-03-27 ================== * Add `103 Early Hints` 1.4.0 / 2017-10-20 ================== * Add `STATUS_CODES` export 1.3.1 / 2016-11-11 ================== * Fix return type in JSDoc 1.3.0 / 2016-05-17 ================== * Add `421 Misdirected Request` * perf: enable strict mode 1.2.1 / 2015-02-01 ================== * Fix message for status 451 - `451 Unavailable For Legal Reasons` 1.2.0 / 2014-09-28 ================== * Add `208 Already Repored` * Add `226 IM Used` * Add `306 (Unused)` * Add `415 Unable For Legal Reasons` * Add `508 Loop Detected` 1.1.1 / 2014-09-24 ================== * Add missing 308 to `codes.json` 1.1.0 / 2014-09-21 ================== * Add `codes.json` for universal support 1.0.4 / 2014-08-20 ================== * Package cleanup 1.0.3 / 2014-06-08 ================== * Add 308 to `.redirect` category 1.0.2 / 2014-03-13 ================== * Add `.retry` category 1.0.1 / 2014-03-12 ================== * Initial release statuses-2.0.1/LICENSE000066400000000000000000000022241377426261700144110ustar00rootroot00000000000000 The MIT License (MIT) Copyright (c) 2014 Jonathan Ong Copyright (c) 2016 Douglas Christopher Wilson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. statuses-2.0.1/README.md000066400000000000000000000067471377426261700147010ustar00rootroot00000000000000# statuses [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Node.js Version][node-version-image]][node-version-url] [![Build Status][ci-image]][ci-url] [![Test Coverage][coveralls-image]][coveralls-url] HTTP status utility for node. This module provides a list of status codes and messages sourced from a few different projects: * The [IANA Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) * The [Node.js project](https://nodejs.org/) * The [NGINX project](https://www.nginx.com/) * The [Apache HTTP Server project](https://httpd.apache.org/) ## Installation This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/). Installation is done using the [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally): ```sh $ npm install statuses ``` ## API ```js var status = require('statuses') ``` ### status(code) Returns the status message string for a known HTTP status code. The code may be a number or a string. An error is thrown for an unknown status code. ```js status(403) // => 'Forbidden' status('403') // => 'Forbidden' status(306) // throws ``` ### status(msg) Returns the numeric status code for a known HTTP status message. The message is case-insensitive. An error is thrown for an unknown status message. ```js status('forbidden') // => 403 status('Forbidden') // => 403 status('foo') // throws ``` ### status.codes Returns an array of all the status codes as `Integer`s. ### status.code[msg] Returns the numeric status code for a known status message (in lower-case), otherwise `undefined`. ```js status['not found'] // => 404 ``` ### status.empty[code] Returns `true` if a status code expects an empty body. ```js status.empty[200] // => undefined status.empty[204] // => true status.empty[304] // => true ``` ### status.message[code] Returns the string message for a known numeric status code, otherwise `undefined`. This object is the same format as the [Node.js http module `http.STATUS_CODES`](https://nodejs.org/dist/latest/docs/api/http.html#http_http_status_codes). ```js status.message[404] // => 'Not Found' ``` ### status.redirect[code] Returns `true` if a status code is a valid redirect status. ```js status.redirect[200] // => undefined status.redirect[301] // => true ``` ### status.retry[code] Returns `true` if you should retry the rest. ```js status.retry[501] // => undefined status.retry[503] // => true ``` ## License [MIT](LICENSE) [ci-image]: https://badgen.net/github/checks/jshttp/statuses/master?label=ci [ci-url]: https://github.com/jshttp/statuses/actions?query=workflow%3Aci [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/statuses/master [coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master [node-version-image]: https://badgen.net/npm/node/statuses [node-version-url]: https://nodejs.org/en/download [npm-downloads-image]: https://badgen.net/npm/dm/statuses [npm-url]: https://npmjs.org/package/statuses [npm-version-image]: https://badgen.net/npm/v/statuses statuses-2.0.1/codes.json000066400000000000000000000033751377426261700154040ustar00rootroot00000000000000{ "100": "Continue", "101": "Switching Protocols", "102": "Processing", "103": "Early Hints", "200": "OK", "201": "Created", "202": "Accepted", "203": "Non-Authoritative Information", "204": "No Content", "205": "Reset Content", "206": "Partial Content", "207": "Multi-Status", "208": "Already Reported", "226": "IM Used", "300": "Multiple Choices", "301": "Moved Permanently", "302": "Found", "303": "See Other", "304": "Not Modified", "305": "Use Proxy", "307": "Temporary Redirect", "308": "Permanent Redirect", "400": "Bad Request", "401": "Unauthorized", "402": "Payment Required", "403": "Forbidden", "404": "Not Found", "405": "Method Not Allowed", "406": "Not Acceptable", "407": "Proxy Authentication Required", "408": "Request Timeout", "409": "Conflict", "410": "Gone", "411": "Length Required", "412": "Precondition Failed", "413": "Payload Too Large", "414": "URI Too Long", "415": "Unsupported Media Type", "416": "Range Not Satisfiable", "417": "Expectation Failed", "418": "I'm a Teapot", "421": "Misdirected Request", "422": "Unprocessable Entity", "423": "Locked", "424": "Failed Dependency", "425": "Too Early", "426": "Upgrade Required", "428": "Precondition Required", "429": "Too Many Requests", "431": "Request Header Fields Too Large", "451": "Unavailable For Legal Reasons", "500": "Internal Server Error", "501": "Not Implemented", "502": "Bad Gateway", "503": "Service Unavailable", "504": "Gateway Timeout", "505": "HTTP Version Not Supported", "506": "Variant Also Negotiates", "507": "Insufficient Storage", "508": "Loop Detected", "509": "Bandwidth Limit Exceeded", "510": "Not Extended", "511": "Network Authentication Required" } statuses-2.0.1/index.js000066400000000000000000000050621377426261700150540ustar00rootroot00000000000000/*! * statuses * Copyright(c) 2014 Jonathan Ong * Copyright(c) 2016 Douglas Christopher Wilson * MIT Licensed */ 'use strict' /** * Module dependencies. * @private */ var codes = require('./codes.json') /** * Module exports. * @public */ module.exports = status // status code to message map status.message = codes // status message (lower-case) to code map status.code = createMessageToStatusCodeMap(codes) // array of status codes status.codes = createStatusCodeList(codes) // status codes for redirects status.redirect = { 300: true, 301: true, 302: true, 303: true, 305: true, 307: true, 308: true } // status codes for empty bodies status.empty = { 204: true, 205: true, 304: true } // status codes for when you should retry the request status.retry = { 502: true, 503: true, 504: true } /** * Create a map of message to status code. * @private */ function createMessageToStatusCodeMap (codes) { var map = {} Object.keys(codes).forEach(function forEachCode (code) { var message = codes[code] var status = Number(code) // populate map map[message.toLowerCase()] = status }) return map } /** * Create a list of all status codes. * @private */ function createStatusCodeList (codes) { return Object.keys(codes).map(function mapCode (code) { return Number(code) }) } /** * Get the status code for given message. * @private */ function getStatusCode (message) { var msg = message.toLowerCase() if (!Object.prototype.hasOwnProperty.call(status.code, msg)) { throw new Error('invalid status message: "' + message + '"') } return status.code[msg] } /** * Get the status message for given code. * @private */ function getStatusMessage (code) { if (!Object.prototype.hasOwnProperty.call(status.message, code)) { throw new Error('invalid status code: ' + code) } return status.message[code] } /** * Get the status code. * * Given a number, this will throw if it is not a known status * code, otherwise the code will be returned. Given a string, * the string will be parsed for a number and return the code * if valid, otherwise will lookup the code assuming this is * the status message. * * @param {string|number} code * @returns {number} * @public */ function status (code) { if (typeof code === 'number') { return getStatusMessage(code) } if (typeof code !== 'string') { throw new TypeError('code must be a number or string') } // '403' var n = parseInt(code, 10) if (!isNaN(n)) { return getStatusMessage(n) } return getStatusCode(code) } statuses-2.0.1/package.json000066400000000000000000000026401377426261700156740ustar00rootroot00000000000000{ "name": "statuses", "description": "HTTP status utility", "version": "2.0.1", "contributors": [ "Douglas Christopher Wilson ", "Jonathan Ong (http://jongleberry.com)" ], "repository": "jshttp/statuses", "license": "MIT", "keywords": [ "http", "status", "code" ], "files": [ "HISTORY.md", "index.js", "codes.json", "LICENSE" ], "devDependencies": { "csv-parse": "4.14.2", "eslint": "7.17.0", "eslint-config-standard": "14.1.1", "eslint-plugin-import": "2.22.1", "eslint-plugin-markdown": "1.0.2", "eslint-plugin-node": "11.1.0", "eslint-plugin-promise": "4.2.1", "eslint-plugin-standard": "4.1.0", "mocha": "8.2.1", "nyc": "15.1.0", "raw-body": "2.4.1", "stream-to-array": "2.3.0" }, "engines": { "node": ">= 0.8" }, "scripts": { "build": "node scripts/build.js", "fetch": "node scripts/fetch-apache.js && node scripts/fetch-iana.js && node scripts/fetch-nginx.js && node scripts/fetch-node.js", "lint": "eslint --plugin markdown --ext js,md .", "test": "mocha --reporter spec --check-leaks --bail test/", "test-ci": "nyc --reporter=lcov --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test", "update": "npm run fetch && npm run build", "version": "node scripts/version-history.js && git add HISTORY.md" } } statuses-2.0.1/scripts/000077500000000000000000000000001377426261700150735ustar00rootroot00000000000000statuses-2.0.1/scripts/build.js000066400000000000000000000011271377426261700165310ustar00rootroot00000000000000'use strict' var path = require('path') var write = require('./lib/write') // all codes var codes = {} // initialize with all IANA codes addData(codes, require('../src/iana.json')) // add the codes from node addData(codes, require('../src/node.json')) // add the codes from nginx addData(codes, require('../src/nginx.json')) // add the codes from apache addData(codes, require('../src/apache.json')) // write the JSON object write(path.join(__dirname, '../codes.json'), codes) function addData (db, obj) { Object.keys(obj).forEach(function (key) { db[key] = db[key] || obj[key] }) } statuses-2.0.1/scripts/fetch-apache.js000066400000000000000000000014021377426261700177360ustar00rootroot00000000000000'use strict' var getBody = require('raw-body') var https = require('https') var path = require('path') var write = require('./lib/write') var URL = 'https://svn.apache.org/repos/asf/httpd/httpd/trunk/modules/http/http_protocol.c' var HEADERS = { 'User-Agent': 'nodejs/' + process.version + ' (' + process.platform + ', npm:statuses)' } https.get(URL, { headers: HEADERS }, function onResponse (res) { getBody(res, true, function (err, body) { if (err) throw err var block = /status_lines\[[^\]]*\]\s*=\s*{([^}]+)};/m.exec(body)[1] var codes = {} var match var regexp = /"([0-9]+) ([^"]+)"/g while ((match = regexp.exec(block))) { codes[match[1]] = match[2] } write(path.join(__dirname, '../src/apache.json'), codes) }) }) statuses-2.0.1/scripts/fetch-iana.js000066400000000000000000000025051377426261700174320ustar00rootroot00000000000000'use strict' var https = require('https') var parser = require('csv-parse') var path = require('path') var toArray = require('stream-to-array') var write = require('./lib/write') var URL = 'https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv' var HEADERS = { 'User-Agent': 'nodejs/' + process.version + ' (' + process.platform + ', npm:statuses)' } https.get(URL, { headers: HEADERS }, function onResponse (res) { toArray(res.pipe(parser()), function (err, rows) { if (err) throw err var codes = {} var headers = rows.shift().map(normalizeHeader) var reduceRows = generateRowMapper(headers) rows.forEach(function (row) { var obj = row.reduce(reduceRows, {}) // skip unassigned codes if (obj.description === 'Unassigned') { return } // skip retired 306 code if (obj.value === '306') { return } codes[obj.value] = obj.description }) write(path.join(__dirname, '../src/iana.json'), codes) }) }) function generateRowMapper (headers) { return function reduceRows (obj, val, index) { if (val !== '') { obj[headers[index]] = val } return obj } } function normalizeHeader (val) { return val.substr(0, 1).toLowerCase() + val.substr(1).replace(/ (.)/, function (s, c) { return c.toUpperCase() }) } statuses-2.0.1/scripts/fetch-nginx.js000066400000000000000000000014221377426261700176420ustar00rootroot00000000000000'use strict' var getBody = require('raw-body') var https = require('https') var path = require('path') var write = require('./lib/write') var URL = 'https://hg.nginx.org/nginx/raw-file/default/src/http/ngx_http_header_filter_module.c' var HEADERS = { 'User-Agent': 'nodejs/' + process.version + ' (' + process.platform + ', npm:statuses)' } https.get(URL, { headers: HEADERS }, function onResponse (res) { getBody(res, true, function (err, body) { if (err) throw err var block = /ngx_http_status_lines\[] = {([^}]+)};/m.exec(body)[1] var codes = {} var match var regexp = /ngx_string\("([0-9]+) ([^"]+)"\)/g while ((match = regexp.exec(block))) { codes[match[1]] = match[2] } write(path.join(__dirname, '../src/nginx.json'), codes) }) }) statuses-2.0.1/scripts/fetch-node.js000066400000000000000000000014261377426261700174500ustar00rootroot00000000000000'use strict' var getBody = require('raw-body') var https = require('https') var path = require('path') var write = require('./lib/write') var URL = 'https://raw.githubusercontent.com/nodejs/node/master/lib/_http_server.js' var HEADERS = { 'User-Agent': 'nodejs/' + process.version + ' (' + process.platform + ', npm:statuses)' } https.get(URL, { headers: HEADERS }, function onResponse (res) { getBody(res, true, function (err, body) { if (err) throw err var block = /STATUS_CODES\s*=\s*{([^}]+)};/m.exec(body)[1] var codes = {} var match var regexp = /([0-9]+): '([^\\']*(?:\\'[^\\']*)*)'/g while ((match = regexp.exec(block))) { codes[match[1]] = match[2].replace(/\\'/g, "'") } write(path.join(__dirname, '../src/node.json'), codes) }) }) statuses-2.0.1/scripts/lib/000077500000000000000000000000001377426261700156415ustar00rootroot00000000000000statuses-2.0.1/scripts/lib/write.js000066400000000000000000000010211377426261700173230ustar00rootroot00000000000000'use strict' var fs = require('fs') module.exports = function write (path, obj) { var fd = fs.openSync(path, 'w') var keys = Object.keys(obj).sort() fs.writeSync(fd, '{\n') keys.forEach(function (key, i, arr) { fs.writeSync(fd, ' ' + JSON.stringify(key) + ': ' + JSON.stringify(obj[key]) + endLine.apply(this, arguments)) }) fs.writeSync(fd, '}\n') fs.closeSync(fd) } function endLine (val, index, array) { var comma = index + 1 === array.length ? '' : ',' return comma + '\n' } statuses-2.0.1/scripts/version-history.js000066400000000000000000000027771377426261700206320ustar00rootroot00000000000000'use strict' var fs = require('fs') var path = require('path') var HISTORY_FILE_PATH = path.join(__dirname, '..', 'HISTORY.md') var MD_HEADER_REGEXP = /^====*$/ var VERSION = process.env.npm_package_version var VERSION_PLACEHOLDER_REGEXP = /^(?:unreleased|(\d+\.)+x)$/ var historyFileLines = fs.readFileSync(HISTORY_FILE_PATH, 'utf-8').split('\n') if (!MD_HEADER_REGEXP.test(historyFileLines[1])) { console.error('Missing header in HISTORY.md') process.exit(1) } if (!VERSION_PLACEHOLDER_REGEXP.test(historyFileLines[0])) { console.error('Missing placegolder version in HISTORY.md') process.exit(1) } if (historyFileLines[0].indexOf('x') !== -1) { var versionCheckRegExp = new RegExp('^' + historyFileLines[0].replace('x', '.+') + '$') if (!versionCheckRegExp.test(VERSION)) { console.error('Version %s does not match placeholder %s', VERSION, historyFileLines[0]) process.exit(1) } } historyFileLines[0] = VERSION + ' / ' + getLocaleDate() historyFileLines[1] = repeat('=', historyFileLines[0].length) fs.writeFileSync(HISTORY_FILE_PATH, historyFileLines.join('\n')) function getLocaleDate () { var now = new Date() return zeroPad(now.getFullYear(), 4) + '-' + zeroPad(now.getMonth() + 1, 2) + '-' + zeroPad(now.getDate(), 2) } function repeat (str, length) { var out = '' for (var i = 0; i < length; i++) { out += str } return out } function zeroPad (number, length) { var num = number.toString() while (num.length < length) { num = '0' + num } return num } statuses-2.0.1/src/000077500000000000000000000000001377426261700141735ustar00rootroot00000000000000statuses-2.0.1/src/apache.json000066400000000000000000000033311377426261700163070ustar00rootroot00000000000000{ "100": "Continue", "101": "Switching Protocols", "102": "Processing", "200": "OK", "201": "Created", "202": "Accepted", "203": "Non-Authoritative Information", "204": "No Content", "205": "Reset Content", "206": "Partial Content", "207": "Multi-Status", "208": "Already Reported", "226": "IM Used", "300": "Multiple Choices", "301": "Moved Permanently", "302": "Found", "303": "See Other", "304": "Not Modified", "305": "Use Proxy", "307": "Temporary Redirect", "308": "Permanent Redirect", "400": "Bad Request", "401": "Unauthorized", "402": "Payment Required", "403": "Forbidden", "404": "Not Found", "405": "Method Not Allowed", "406": "Not Acceptable", "407": "Proxy Authentication Required", "408": "Request Timeout", "409": "Conflict", "410": "Gone", "411": "Length Required", "412": "Precondition Failed", "413": "Request Entity Too Large", "414": "Request-URI Too Long", "415": "Unsupported Media Type", "416": "Requested Range Not Satisfiable", "417": "Expectation Failed", "418": "I'm A Teapot", "421": "Misdirected Request", "422": "Unprocessable Entity", "423": "Locked", "424": "Failed Dependency", "425": "Too Early", "426": "Upgrade Required", "428": "Precondition Required", "429": "Too Many Requests", "431": "Request Header Fields Too Large", "451": "Unavailable For Legal Reasons", "500": "Internal Server Error", "501": "Not Implemented", "502": "Bad Gateway", "503": "Service Unavailable", "504": "Gateway Timeout", "505": "HTTP Version Not Supported", "506": "Variant Also Negotiates", "507": "Insufficient Storage", "508": "Loop Detected", "510": "Not Extended", "511": "Network Authentication Required" } statuses-2.0.1/src/iana.json000066400000000000000000000032771377426261700160070ustar00rootroot00000000000000{ "100": "Continue", "101": "Switching Protocols", "102": "Processing", "103": "Early Hints", "200": "OK", "201": "Created", "202": "Accepted", "203": "Non-Authoritative Information", "204": "No Content", "205": "Reset Content", "206": "Partial Content", "207": "Multi-Status", "208": "Already Reported", "226": "IM Used", "300": "Multiple Choices", "301": "Moved Permanently", "302": "Found", "303": "See Other", "304": "Not Modified", "305": "Use Proxy", "307": "Temporary Redirect", "308": "Permanent Redirect", "400": "Bad Request", "401": "Unauthorized", "402": "Payment Required", "403": "Forbidden", "404": "Not Found", "405": "Method Not Allowed", "406": "Not Acceptable", "407": "Proxy Authentication Required", "408": "Request Timeout", "409": "Conflict", "410": "Gone", "411": "Length Required", "412": "Precondition Failed", "413": "Payload Too Large", "414": "URI Too Long", "415": "Unsupported Media Type", "416": "Range Not Satisfiable", "417": "Expectation Failed", "421": "Misdirected Request", "422": "Unprocessable Entity", "423": "Locked", "424": "Failed Dependency", "425": "Too Early", "426": "Upgrade Required", "428": "Precondition Required", "429": "Too Many Requests", "431": "Request Header Fields Too Large", "451": "Unavailable For Legal Reasons", "500": "Internal Server Error", "501": "Not Implemented", "502": "Bad Gateway", "503": "Service Unavailable", "504": "Gateway Timeout", "505": "HTTP Version Not Supported", "506": "Variant Also Negotiates", "507": "Insufficient Storage", "508": "Loop Detected", "510": "Not Extended", "511": "Network Authentication Required" } statuses-2.0.1/src/nginx.json000066400000000000000000000017761377426261700162240ustar00rootroot00000000000000{ "200": "OK", "201": "Created", "202": "Accepted", "204": "No Content", "206": "Partial Content", "301": "Moved Permanently", "302": "Moved Temporarily", "303": "See Other", "304": "Not Modified", "307": "Temporary Redirect", "308": "Permanent Redirect", "400": "Bad Request", "401": "Unauthorized", "402": "Payment Required", "403": "Forbidden", "404": "Not Found", "405": "Not Allowed", "406": "Not Acceptable", "408": "Request Time-out", "409": "Conflict", "410": "Gone", "411": "Length Required", "412": "Precondition Failed", "413": "Request Entity Too Large", "414": "Request-URI Too Large", "415": "Unsupported Media Type", "416": "Requested Range Not Satisfiable", "421": "Misdirected Request", "429": "Too Many Requests", "500": "Internal Server Error", "501": "Not Implemented", "502": "Bad Gateway", "503": "Service Temporarily Unavailable", "504": "Gateway Time-out", "505": "HTTP Version Not Supported", "507": "Insufficient Storage" } statuses-2.0.1/src/node.json000066400000000000000000000033751377426261700160230ustar00rootroot00000000000000{ "100": "Continue", "101": "Switching Protocols", "102": "Processing", "103": "Early Hints", "200": "OK", "201": "Created", "202": "Accepted", "203": "Non-Authoritative Information", "204": "No Content", "205": "Reset Content", "206": "Partial Content", "207": "Multi-Status", "208": "Already Reported", "226": "IM Used", "300": "Multiple Choices", "301": "Moved Permanently", "302": "Found", "303": "See Other", "304": "Not Modified", "305": "Use Proxy", "307": "Temporary Redirect", "308": "Permanent Redirect", "400": "Bad Request", "401": "Unauthorized", "402": "Payment Required", "403": "Forbidden", "404": "Not Found", "405": "Method Not Allowed", "406": "Not Acceptable", "407": "Proxy Authentication Required", "408": "Request Timeout", "409": "Conflict", "410": "Gone", "411": "Length Required", "412": "Precondition Failed", "413": "Payload Too Large", "414": "URI Too Long", "415": "Unsupported Media Type", "416": "Range Not Satisfiable", "417": "Expectation Failed", "418": "I'm a Teapot", "421": "Misdirected Request", "422": "Unprocessable Entity", "423": "Locked", "424": "Failed Dependency", "425": "Too Early", "426": "Upgrade Required", "428": "Precondition Required", "429": "Too Many Requests", "431": "Request Header Fields Too Large", "451": "Unavailable For Legal Reasons", "500": "Internal Server Error", "501": "Not Implemented", "502": "Bad Gateway", "503": "Service Unavailable", "504": "Gateway Timeout", "505": "HTTP Version Not Supported", "506": "Variant Also Negotiates", "507": "Insufficient Storage", "508": "Loop Detected", "509": "Bandwidth Limit Exceeded", "510": "Not Extended", "511": "Network Authentication Required" } statuses-2.0.1/test/000077500000000000000000000000001377426261700143635ustar00rootroot00000000000000statuses-2.0.1/test/.eslintrc.yml000066400000000000000000000000231377426261700170020ustar00rootroot00000000000000env: mocha: true statuses-2.0.1/test/test.js000066400000000000000000000100661377426261700157030ustar00rootroot00000000000000 var assert = require('assert') var http = require('http') var status = require('..') describe('status', function () { describe('arguments', function () { describe('code', function () { it('should be required', function () { assert.throws(status, /code must be/) }) it('should accept a number', function () { assert.strictEqual(status(200), 'OK') }) it('should accept a string', function () { assert.strictEqual(status('OK'), 200) }) it('should accept a string number', function () { assert.strictEqual(status('200'), 'OK') }) it('should reject an object', function () { assert.throws(status.bind(null, {}), /code must be/) }) }) }) describe('when given a number', function () { it('should return message when a valid status code', function () { assert.strictEqual(status(200), 'OK') assert.strictEqual(status(404), 'Not Found') assert.strictEqual(status(500), 'Internal Server Error') }) it('should throw for invalid status code', function () { assert.throws(status.bind(null, 0), /invalid status code/) assert.throws(status.bind(null, 1000), /invalid status code/) }) it('should throw for unknown status code', function () { assert.throws(status.bind(null, 299), /invalid status code/) assert.throws(status.bind(null, 310), /invalid status code/) }) it('should throw for discontinued status code', function () { assert.throws(status.bind(null, 306), /invalid status code/) }) }) describe('when given a string', function () { it('should return message when a valid status code', function () { assert.strictEqual(status('200'), 'OK') assert.strictEqual(status('404'), 'Not Found') assert.strictEqual(status('500'), 'Internal Server Error') }) it('should be truthy when a valid status message', function () { assert.ok(status('OK')) assert.ok(status('Not Found')) assert.ok(status('Internal Server Error')) }) it('should be case insensitive', function () { assert.ok(status('Ok')) assert.ok(status('not found')) assert.ok(status('INTERNAL SERVER ERROR')) }) it('should throw for unknown status message', function () { assert.throws(status.bind(null, 'too many bugs'), /invalid status message/) assert.throws(status.bind(null, 'constructor'), /invalid status message/) assert.throws(status.bind(null, '__proto__'), /invalid status message/) }) it('should throw for unknown status code', function () { assert.throws(status.bind(null, '299'), /invalid status code/) }) }) describe('.codes', function () { it('should include codes from Node.js', function () { Object.keys(http.STATUS_CODES).forEach(function forEachCode (code) { assert.notStrictEqual(status.codes.indexOf(Number(code)), -1, 'contains ' + code) }) }) }) describe('.empty', function () { it('should be an object', function () { assert.ok(status.empty) assert.strictEqual(typeof status.empty, 'object') }) it('should include 204', function () { assert(status.empty[204]) }) }) describe('.message', function () { it('should be a map of code to message', function () { assert.strictEqual(status.message[200], 'OK') }) it('should include codes from Node.js', function () { Object.keys(http.STATUS_CODES).forEach(function forEachCode (code) { assert.ok(status.message[code], 'contains ' + code) }) }) }) describe('.redirect', function () { it('should be an object', function () { assert.ok(status.redirect) assert.strictEqual(typeof status.redirect, 'object') }) it('should include 308', function () { assert(status.redirect[308]) }) }) describe('.retry', function () { it('should be an object', function () { assert.ok(status.retry) assert.strictEqual(typeof status.retry, 'object') }) it('should include 504', function () { assert(status.retry[504]) }) }) })