pax_global_header00006660000000000000000000000064150362327050014515gustar00rootroot0000000000000052 comment=81090b8293cade5e4d9a9cd5a6536d19b4530762 expressjs-response-time-81090b8/000077500000000000000000000000001503623270500166105ustar00rootroot00000000000000expressjs-response-time-81090b8/.eslintignore000066400000000000000000000000261503623270500213110ustar00rootroot00000000000000coverage node_modules expressjs-response-time-81090b8/.eslintrc000066400000000000000000000000341503623270500204310ustar00rootroot00000000000000{ "extends": "standard" } expressjs-response-time-81090b8/.github/000077500000000000000000000000001503623270500201505ustar00rootroot00000000000000expressjs-response-time-81090b8/.github/dependabot.yml000066400000000000000000000005041503623270500227770ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: github-actions directory: / schedule: interval: monthly - package-ecosystem: npm directory: / schedule: interval: monthly open-pull-requests-limit: 10 ignore: - dependency-name: "*" update-types: ["version-update:semver-major"] expressjs-response-time-81090b8/.github/workflows/000077500000000000000000000000001503623270500222055ustar00rootroot00000000000000expressjs-response-time-81090b8/.github/workflows/ci.yml000066400000000000000000000137711503623270500233340ustar00rootroot00000000000000name: ci on: pull_request: branches: - master push: branches: - master permissions: contents: read jobs: test: permissions: checks: write # for coverallsapp/github-action to create new checks contents: read # for actions/checkout to fetch code 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 - Node.js 16.x - Node.js 17.x - Node.js 18.x - Node.js 19.x - Node.js 20.x - Node.js 21.x - Node.js 22.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.1.2 nyc@14.1.1 - name: Node.js 9.x node-version: "9.11" npm-i: mocha@7.1.2 nyc@14.1.1 - name: Node.js 10.x node-version: "10.24" npm-i: mocha@8.4.0 - name: Node.js 11.x node-version: "11.15" npm-i: mocha@8.4.0 - name: Node.js 12.x node-version: "12.22" npm-i: mocha@9.2.2 - name: Node.js 13.x node-version: "13.14" npm-i: mocha@9.2.2 - name: Node.js 14.x node-version: "14.21" - name: Node.js 15.x node-version: "15.14" - name: Node.js 16.x node-version: "16.20" - name: Node.js 17.x node-version: "17.9" - name: Node.js 18.x node-version: "18.18" - name: Node.js 19.x node-version: "19" - name: Node.js 20.x node-version: "20" - name: Node.js 21.x node-version: "21" - name: Node.js 22.x node-version: "22" steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install Node.js ${{ matrix.node-version }} shell: bash -eo pipefail -l {0} run: | nvm install --default ${{ matrix.node-version }} if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then nvm install --alias=npm 0.10 nvm use ${{ matrix.node-version }} if [[ "$(npm -v)" == 1.1.* ]]; then nvm exec npm npm install -g npm@1.1 ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" else sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" fi npm config set strict-ssl false fi dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" - name: Configure npm run: | if [[ "$(npm config get package-lock)" == "true" ]]; then npm config set package-lock false else npm config set shrinkwrap false fi - 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 < 8 if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 8 ]]; 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@648a8eb78e6d50909eff900e4ec85cab4524a45b # master if: steps.list_env.outputs.nyc != '' with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.test_number }} parallel: true coverage: permissions: checks: write # for coverallsapp/github-action to create new checks needs: test runs-on: ubuntu-latest steps: - name: Upload code coverage uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # master with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true expressjs-response-time-81090b8/.github/workflows/codeql.yml000066400000000000000000000046441503623270500242070ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: ["master"] pull_request: # The branches below must be a subset of the branches above branches: ["master"] schedule: - cron: "0 0 * * 1" permissions: contents: read jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2 with: languages: javascript # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) # - name: Autobuild # uses: github/codeql-action/autobuild@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun # If the Autobuild fails above, remove it and uncomment the following three lines. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # - run: | # echo "Run, Build Application using script" # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2 with: category: "/language:javascript"expressjs-response-time-81090b8/.github/workflows/scorecards.yml000066400000000000000000000057321503623270500250670ustar00rootroot00000000000000# This workflow uses actions that are not certified by GitHub. They are provided # by a third-party and are governed by separate terms of service, privacy # policy, and support documentation. name: Scorecard supply-chain security on: # For Branch-Protection check. Only the default branch is supported. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection branch_protection_rule: # To guarantee Maintained check is occasionally updated. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained schedule: - cron: '20 7 * * 2' push: branches: ["master"] # Declare default permissions as read only. permissions: read-all jobs: analysis: name: Scorecard analysis runs-on: ubuntu-latest permissions: # Needed to upload the results to code-scanning dashboard. security-events: write # Needed to publish results and get a badge (see publish_results below). id-token: write contents: read actions: read # To allow GraphQL ListCommits to work issues: read pull-requests: read # To detect SAST tools checks: read steps: - name: "Checkout code" uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - name: "Run analysis" uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2 with: results_file: results.sarif results_format: sarif # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: # - you want to enable the Branch-Protection check on a *public* repository, or # - you are installing Scorecards on a *private* repository # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. # repo_token: ${{ secrets.SCORECARD_TOKEN }} # Public repositories: # - Publish results to OpenSSF REST API for easy access by consumers # - Allows the repository to include the Scorecard badge. # - See https://github.com/ossf/scorecard-action#publishing-results. # For private repositories: # - `publish_results` will always be set to `false`, regardless # of the value entered here. publish_results: true # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: SARIF file path: results.sarif retention-days: 5 # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" uses: github/codeql-action/upload-sarif@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2 with: sarif_file: results.sarif expressjs-response-time-81090b8/.gitignore000066400000000000000000000000671503623270500206030ustar00rootroot00000000000000coverage/ node_modules/ npm-debug.log package-lock.jsonexpressjs-response-time-81090b8/HISTORY.md000066400000000000000000000026011503623270500202720ustar00rootroot000000000000002.3.4 / 2025-07-17 ========== * deps: on-headers@~1.1.0 - Fix [CVE-2025-7339](https://www.cve.org/CVERecord?id=CVE-2025-7339) ([GHSA-76c9-3jph-rj3q](https://github.com/expressjs/on-headers/security/advisories/GHSA-76c9-3jph-rj3q)) 2.3.3 / 2024-10-07 ========== * deps: depd@~2.0.0 - Remove remove use of `eval` * deps: depd@~1.1.2 - Remove unnecessary `Buffer` loading - perf: remove argument reassignment 2.3.2 / 2015-11-15 ================== * deps: depd@~1.1.0 - Enable strict mode in more places - Support web browser loading * deps: on-headers@~1.0.1 - perf: enable strict mode * perf: enable strict mode 2.3.1 / 2015-05-14 ================== * deps: depd@~1.0.1 2.3.0 / 2015-02-15 ================== * Add function argument to support recording of response time 2.2.0 / 2014-09-22 ================== * Add `suffix` option * deps: depd@~1.0.0 2.1.0 / 2014-09-16 ================== * Add `header` option for custom header name * Change `digits` argument to an `options` argument 2.0.1 / 2014-08-10 ================== * deps: on-headers@~1.0.0 2.0.0 / 2014-05-31 ================== * add `digits` argument * do not override existing `X-Response-Time` header * timer not subject to clock drift * timer resolution down to nanoseconds * use `on-headers` module 1.0.0 / 2014-02-08 ================== * Genesis from `connect` expressjs-response-time-81090b8/LICENSE000066400000000000000000000022241503623270500176150ustar00rootroot00000000000000(The MIT License) Copyright (c) 2014 Jonathan Ong Copyright (c) 2014-2015 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. expressjs-response-time-81090b8/README.md000066400000000000000000000072271503623270500200770ustar00rootroot00000000000000# response-time [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Node.js Version][node-image]][node-url] [![Build Status][ci-image]][ci-url] [![Test Coverage][coveralls-image]][coveralls-url] Response time for Node.js servers. This module creates a middleware that records the response time for requests in HTTP servers. The "response time" is defined here as the elapsed time from when a request enters this middleware to when the headers are written out to the client. ## 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 response-time ``` ## API ```js var responseTime = require('response-time') ``` ### responseTime([options]) Create a middleware that adds a `X-Response-Time` header to responses. If you don't want to use this module to automatically set a header, please see the section about [`responseTime(fn)`](#responsetimefn). #### Options The `responseTime` function accepts an optional `options` object that may contain any of the following keys: ##### digits The fixed number of digits to include in the output, which is always in milliseconds, defaults to `3` (ex: `2.300ms`). ##### header The name of the header to set, defaults to `X-Response-Time`. ##### suffix Boolean to indicate if units of measurement suffix should be added to the output, defaults to `true` (ex: `2.300ms` vs `2.300`). ### responseTime(fn) Create a new middleware that records the response time of a request and makes this available to your own function `fn`. The `fn` argument will be invoked as `fn(req, res, time)`, where `time` is a number in milliseconds. ## Examples ### express/connect ```js var express = require('express') var responseTime = require('response-time') var app = express() app.use(responseTime()) app.get('/', function (req, res) { res.send('hello, world!') }) ``` ### vanilla http server ```js var finalhandler = require('finalhandler') var http = require('http') var responseTime = require('response-time') // create "middleware" var _responseTime = responseTime() http.createServer(function (req, res) { var done = finalhandler(req, res) _responseTime(req, res, function (err) { if (err) return done(err) // respond to request res.setHeader('content-type', 'text/plain') res.end('hello, world!') }) }) ``` ### response time metrics ```js var express = require('express') var responseTime = require('response-time') var StatsD = require('node-statsd') var app = express() var stats = new StatsD() stats.socket.on('error', function (error) { console.error(error.stack) }) app.use(responseTime(function (req, res, time) { var stat = (req.method + req.url).toLowerCase() .replace(/[:.]/g, '') .replace(/\//g, '_') stats.timing(stat, time) })) app.get('/', function (req, res) { res.send('hello, world!') }) ``` ## License [MIT](LICENSE) [npm-version-image]: https://badgen.net/npm/v/response-time [npm-url]: https://npmjs.org/package/response-time [npm-downloads-image]: https://badgen.net/npm/dm/response-time [node-image]: https://badgen.net/npm/node/response-time [node-url]: https://nodejs.org/en/download [ci-image]: https://badgen.net/github/checks/express/response-time/master?label=ci [ci-url]: https://github.com/express/response-time/actions/workflows/ci.yml [coveralls-image]: https://badgen.net/coveralls/c/github/express/response-time/master [coveralls-url]: https://coveralls.io/r/express/response-time?branch=master expressjs-response-time-81090b8/index.js000066400000000000000000000036441503623270500202640ustar00rootroot00000000000000/*! * response-time * Copyright(c) 2011 TJ Holowaychuk * Copyright(c) 2014 Jonathan Ong * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ 'use strict' /** * Module dependencies * @private */ var deprecate = require('depd')('response-time') var onHeaders = require('on-headers') /** * Module exports. * @public */ module.exports = responseTime /** * Create a middleware to add a `X-Response-Time` header displaying * the response duration in milliseconds. * * @param {object|function} [options] * @param {number} [options.digits=3] * @param {string} [options.header=X-Response-Time] * @param {boolean} [options.suffix=true] * @return {function} * @public */ function responseTime (options) { var opts = options || {} if (typeof options === 'number') { // back-compat single number argument deprecate('number argument: use {digits: ' + JSON.stringify(options) + '} instead') opts = { digits: options } } // get the function to invoke var fn = typeof opts !== 'function' ? createSetHeader(opts) : opts return function responseTime (req, res, next) { var startAt = process.hrtime() onHeaders(res, function onHeaders () { var diff = process.hrtime(startAt) var time = diff[0] * 1e3 + diff[1] * 1e-6 fn(req, res, time) }) next() } } /** * Create function to set response time header. * @private */ function createSetHeader (options) { // response time digits var digits = options.digits !== undefined ? options.digits : 3 // header name var header = options.header || 'X-Response-Time' // display suffix var suffix = options.suffix !== undefined ? Boolean(options.suffix) : true return function setResponseHeader (req, res, time) { if (res.getHeader(header)) { return } var val = time.toFixed(digits) if (suffix) { val += 'ms' } res.setHeader(header, val) } } expressjs-response-time-81090b8/package.json000066400000000000000000000022701503623270500210770ustar00rootroot00000000000000{ "name": "response-time", "description": "Response time for Node.js servers", "version": "2.3.4", "author": "Jonathan Ong (http://jongleberry.com)", "contributors": [ "Douglas Christopher Wilson " ], "license": "MIT", "keywords": [ "http", "res", "response time", "x-response-time" ], "repository": "expressjs/response-time", "dependencies": { "depd": "~2.0.0", "on-headers": "~1.1.0" }, "devDependencies": { "after": "0.8.2", "eslint": "4.19.1", "eslint-config-standard": "11.0.0", "eslint-plugin-import": "2.32.0", "eslint-plugin-markdown": "1.0.2", "eslint-plugin-node": "6.0.1", "eslint-plugin-promise": "3.8.0", "eslint-plugin-standard": "3.1.0", "mocha": "6.2.3", "nyc": "14.1.1", "supertest": "1.1.0" }, "files": [ "LICENSE", "HISTORY.md", "index.js" ], "engines": { "node": ">= 0.8.0" }, "scripts": { "lint": "eslint --plugin markdown --ext js,md .", "test": "mocha --reporter spec", "test-ci": "nyc --reporter=lcovonly --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test" } } expressjs-response-time-81090b8/test/000077500000000000000000000000001503623270500175675ustar00rootroot00000000000000expressjs-response-time-81090b8/test/.eslintrc000066400000000000000000000000441503623270500214110ustar00rootroot00000000000000{ "env": { "mocha": true } } expressjs-response-time-81090b8/test/test.js000066400000000000000000000103251503623270500211050ustar00rootroot00000000000000 process.env.NO_DEPRECATION = 'response-time' var after = require('after') var assert = require('assert') var http = require('http') var request = require('supertest') var responseTime = require('..') describe('responseTime()', function () { it('should send X-Response-Time header', function (done) { var server = createServer() request(server) .get('/') .expect('X-Response-Time', /^[0-9.]+ms$/, done) }) it('should not override X-Response-Time header', function (done) { var server = createServer(undefined, function (req, res) { res.setHeader('X-Response-Time', 'bogus') }) request(server) .get('/') .expect('X-Response-Time', 'bogus', done) }) describe('with "digits"', function () { it('should default to 3', function (done) { var server = createServer() request(server) .get('/') .expect('X-Response-Time', /^[0-9]+\.[0-9]{3}ms$/, done) }) it('should allow custom digits', function (done) { var server = createServer(5) request(server) .get('/') .expect('X-Response-Time', /^[0-9]+\.[0-9]{5}ms$/, done) }) it('should allow no digits', function (done) { var server = createServer(0) request(server) .get('/') .expect('X-Response-Time', /^[0-9]+ms$/, done) }) }) }) describe('responseTime(fn)', function () { it('should call fn with response time', function (done) { var cb = after(2, done) var start = process.hrtime() var server = createServer(function (req, res, time) { var diff = process.hrtime(start) var max = diff[0] * 1e3 + diff[1] * 1e-6 assert.equal(req.url, '/') assert.equal(res.statusCode, 200) assert.ok(time >= 0) assert.ok(time <= max) cb() }) request(server) .get('/') .expect(200, cb) }) it('should not send X-Response-Time header', function (done) { var cb = after(2, done) var server = createServer(function () { cb() }) request(server) .get('/') .expect(shouldNotHaveHeader('X-Response-Time')) .expect(200, cb) }) }) describe('responseTime(options)', function () { describe('with "digits" option', function () { it('should default to 3', function (done) { var server = createServer() request(server) .get('/') .expect('X-Response-Time', /^[0-9]+\.[0-9]{3}ms$/, done) }) it('should allow custom digits', function (done) { var server = createServer({ digits: 5 }) request(server) .get('/') .expect('X-Response-Time', /^[0-9]+\.[0-9]{5}ms$/, done) }) it('should allow no digits', function (done) { var server = createServer({ digits: 0 }) request(server) .get('/') .expect('X-Response-Time', /^[0-9]+ms$/, done) }) }) describe('with "header" option', function () { it('should default to X-Response-Time', function (done) { var server = createServer() request(server) .get('/') .expect('X-Response-Time', /^[0-9.]+ms$/, done) }) it('should allow custom header name', function (done) { var server = createServer({ header: 'X-Time-Taken' }) request(server) .get('/') .expect('X-Time-Taken', /^[0-9.]+ms$/, done) }) }) describe('with "suffix" option', function () { it('should default to true', function (done) { var server = createServer() request(server) .get('/') .expect('X-Response-Time', /^[0-9.]+ms$/, done) }) it('should allow disabling suffix', function (done) { var server = createServer({ suffix: false }) request(server) .get('/') .expect('X-Response-Time', /^[0-9.]+$/, done) }) }) }) function createServer (opts, fn) { var _responseTime = responseTime(opts) return http.createServer(function (req, res) { _responseTime(req, res, function (err) { setTimeout(function () { fn && fn(req, res) res.statusCode = err ? (err.status || 500) : 200 res.end(err ? err.message : 'OK') }, 10) }) }) } function shouldNotHaveHeader (header) { return function (res) { assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header) } }