[
  {
    "path": ".eslintignore",
    "content": ".nyc_output\ncoverage\nnode_modules\n"
  },
  {
    "path": ".eslintrc.yml",
    "content": "root: true\nextends: standard\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: github-actions\n    directory: /\n    schedule:\n      interval: monthly\n\n  - package-ecosystem: npm\n    directory: /\n    schedule:\n      interval: monthly\n    open-pull-requests-limit: 10\n    ignore:\n      - dependency-name: \"*\"\n        update-types: [\"version-update:semver-major\"]\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: ci\n\non:\n- pull_request\n- push\n\npermissions:\n  contents: read\n\njobs:\n  test:\n    permissions:\n      checks: write  # for coverallsapp/github-action to create new checks\n      contents: read  # for actions/checkout to fetch code\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        name:\n        - Node.js 0.8\n        - Node.js 0.10\n        - Node.js 0.12\n        - io.js 1.x\n        - io.js 2.x\n        - io.js 3.x\n        - Node.js 4.x\n        - Node.js 5.x\n        - Node.js 6.x\n        - Node.js 7.x\n        - Node.js 8.x\n        - Node.js 9.x\n        - Node.js 10.x\n        - Node.js 11.x\n        - Node.js 12.x\n        - Node.js 13.x\n        - Node.js 14.x\n        - Node.js 15.x\n        - Node.js 16.x\n        - Node.js 17.x\n        - Node.js 18.x\n        - Node.js 19.x\n        - Node.js 20.x\n        - Node.js 21.x\n        - Node.js 22.x\n\n        include:\n        - name: Node.js 0.8\n          node-version: \"0.8\"\n          npm-i: mocha@2.5.3 supertest@1.1.0\n          npm-rm: nyc\n\n        - name: Node.js 0.10\n          node-version: \"0.10\"\n          npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0\n\n        - name: Node.js 0.12\n          node-version: \"0.12\"\n          npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0\n\n        - name: io.js 1.x\n          node-version: \"1.8\"\n          npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0\n\n        - name: io.js 2.x\n          node-version: \"2.5\"\n          npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0\n\n        - name: io.js 3.x\n          node-version: \"3.3\"\n          npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.0\n\n        - name: Node.js 4.x\n          node-version: \"4.9\"\n          npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2\n\n        - name: Node.js 5.x\n          node-version: \"5.12\"\n          npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2\n\n        - name: Node.js 6.x\n          node-version: \"6.17\"\n          npm-i: mocha@6.2.2 nyc@14.1.1\n\n        - name: Node.js 7.x\n          node-version: \"7.10\"\n          npm-i: mocha@6.2.2 nyc@14.1.1\n\n        - name: Node.js 8.x\n          node-version: \"8.17\"\n          npm-i: mocha@7.1.2 nyc@14.1.1\n\n        - name: Node.js 9.x\n          node-version: \"9.11\"\n          npm-i: mocha@7.1.2 nyc@14.1.1\n\n        - name: Node.js 10.x\n          node-version: \"10.24\"\n          npm-i: mocha@8.4.0\n\n        - name: Node.js 11.x\n          node-version: \"11.15\"\n          npm-i: mocha@8.4.0\n\n        - name: Node.js 12.x\n          node-version: \"12.22\"\n          npm-i: mocha@9.2.2\n\n        - name: Node.js 13.x\n          node-version: \"13.14\"\n          npm-i: mocha@9.2.2\n\n        - name: Node.js 14.x\n          node-version: \"14.21\"\n\n        - name: Node.js 15.x\n          node-version: \"15.14\"\n\n        - name: Node.js 16.x\n          node-version: \"16.20\"\n\n        - name: Node.js 17.x\n          node-version: \"17.9\"\n\n        - name: Node.js 18.x\n          node-version: \"18.18\"\n\n        - name: Node.js 19.x\n          node-version: \"19.9\"\n\n        - name: Node.js 20.x\n          node-version: \"20.9\"\n\n        - name: Node.js 21.x\n          node-version: \"21.1\"\n\n        - name: Node.js 22.x\n          node-version: \"22.0\"\n\n    steps:\n    - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1\n\n    - name: Install Node.js ${{ matrix.node-version }}\n      shell: bash -eo pipefail -l {0}\n      run: |\n        nvm install --default ${{ matrix.node-version }}\n        if [[ \"${{ matrix.node-version }}\" == 0.* && \"$(cut -d. -f2 <<< \"${{ matrix.node-version }}\")\" -lt 10 ]]; then\n          nvm install --alias=npm 0.10\n          nvm use ${{ matrix.node-version }}\n          if [[ \"$(npm -v)\" == 1.1.* ]]; then\n            nvm exec npm npm install -g npm@1.1\n            ln -fs \"$(which npm)\" \"$(dirname \"$(nvm which npm)\")/npm\"\n          else\n            sed -i '1s;^.*$;'\"$(printf '#!%q' \"$(nvm which npm)\")\"';' \"$(readlink -f \"$(which npm)\")\"\n          fi\n          npm config set strict-ssl false\n        fi\n        dirname \"$(nvm which ${{ matrix.node-version }})\" >> \"$GITHUB_PATH\"\n\n    - name: Configure npm\n      run: |\n        if [[ \"$(npm config get package-lock)\" == \"true\" ]]; then\n          npm config set package-lock false\n        else\n          npm config set shrinkwrap false\n        fi\n\n    - name: Remove npm module(s) ${{ matrix.npm-rm }}\n      run: npm rm --silent --save-dev ${{ matrix.npm-rm }}\n      if: matrix.npm-rm != ''\n\n    - name: Install npm module(s) ${{ matrix.npm-i }}\n      run: npm install --save-dev ${{ matrix.npm-i }}\n      if: matrix.npm-i != ''\n\n    - name: Setup Node.js version-specific dependencies\n      shell: bash\n      run: |\n        # eslint for linting\n        # - remove on Node.js < 12\n        if [[ \"$(cut -d. -f1 <<< \"${{ matrix.node-version }}\")\" -lt 12 ]]; then\n          node -pe 'Object.keys(require(\"./package\").devDependencies).join(\"\\n\")' | \\\n            grep -E '^eslint(-|$)' | \\\n            sort -r | \\\n            xargs -n1 npm rm --silent --save-dev\n        fi\n\n    - name: Install Node.js dependencies\n      run: npm install\n\n    - name: List environment\n      id: list_env\n      shell: bash\n      run: |\n        echo \"node@$(node -v)\"\n        echo \"npm@$(npm -v)\"\n        npm -s ls ||:\n        (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 \"=\" $3 }' >> \"$GITHUB_OUTPUT\"\n\n    - name: Run tests\n      shell: bash\n      run: |\n        if npm -ps ls nyc | grep -q nyc; then\n          npm run test-ci\n        else\n          npm test\n        fi\n\n    - name: Lint code\n      if: steps.list_env.outputs.eslint != ''\n      run: npm run lint\n\n    - name: Collect code coverage\n      uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6\n      if: steps.list_env.outputs.nyc != ''\n      with:\n        github-token: ${{ secrets.GITHUB_TOKEN }}\n        flag-name: run-${{ matrix.test_number }}\n        parallel: true\n\n  coverage:\n    permissions:\n      checks: write  # for coverallsapp/github-action to create new checks\n    needs: test\n    runs-on: ubuntu-latest\n    steps:\n    - name: Upload code coverage\n      uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6\n      with:\n        github-token: ${{ secrets.GITHUB_TOKEN }}\n        parallel-finished: true\n"
  },
  {
    "path": ".github/workflows/codeql.yml",
    "content": "# For most projects, this workflow file will not need changing; you simply need\n# to commit it to your repository.\n#\n# You may wish to alter this file to override the set of languages analyzed,\n# or to provide custom queries or build logic.\n#\n# ******** NOTE ********\n# We have attempted to detect the languages in your repository. Please check\n# the `language` matrix defined below to confirm you have the correct set of\n# supported CodeQL languages.\n#\nname: \"CodeQL\"\n\non:\n  push:\n    branches: [\"master\"]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [\"master\"]\n  schedule:\n    - cron: \"0 0 * * 1\"\n\npermissions:\n  contents: read\n\njobs:\n  analyze:\n    name: Analyze\n    runs-on: ubuntu-latest\n    permissions:\n      actions: read\n      contents: read\n      security-events: write\n\n    strategy:\n      fail-fast: false\n      matrix:\n        language: [\"javascript\"]\n        # CodeQL supports [ $supported-codeql-languages ]\n        # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support\n\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1\n\n      # Initializes the CodeQL tools for scanning.\n      - name: Initialize CodeQL\n        uses: github/codeql-action/init@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4\n        with:\n          languages: ${{ matrix.language }}\n          # If you wish to specify custom queries, you can do so here or in a config file.\n          # By default, queries listed here will override any specified in a config file.\n          # Prefix the list here with \"+\" to use these queries and those in the config file.\n\n      # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).\n      # If this step fails, then you should remove it and run the build manually (see below)\n      - name: Autobuild\n        uses: github/codeql-action/autobuild@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4\n\n      # ℹ️ Command-line programs to run using the OS shell.\n      # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun\n\n      #   If the Autobuild fails above, remove it and uncomment the following three lines.\n      #   modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.\n\n      # - run: |\n      #   echo \"Run, Build Application using script\"\n      #   ./location_of_script_within_repo/buildscript.sh\n\n      - name: Perform CodeQL Analysis\n        uses: github/codeql-action/analyze@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4\n        with:\n          category: \"/language:${{matrix.language}}\"\n"
  },
  {
    "path": ".github/workflows/scorecard.yml",
    "content": "# This workflow uses actions that are not certified by GitHub. They are provided\n# by a third-party and are governed by separate terms of service, privacy\n# policy, and support documentation.\n\nname: Scorecard supply-chain security\n\non:\n  # For Branch-Protection check. Only the default branch is supported. See\n  # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection\n  branch_protection_rule:\n  # To guarantee Maintained check is occasionally updated. See\n  # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained\n  schedule:\n    - cron: '16 21 * * 1'\n  push:\n    branches: [ \"master\" ]\n\n# Declare default permissions as read only.\npermissions: read-all\n\njobs:\n  analysis:\n    name: Scorecard analysis\n    runs-on: ubuntu-latest\n    permissions:\n      # Needed to upload the results to code-scanning dashboard.\n      security-events: write\n      # Needed to publish results and get a badge (see publish_results below).\n      id-token: write\n      # Uncomment the permissions below if installing in a private repository.\n      # contents: read\n      # actions: read\n\n    steps:\n      - name: \"Checkout code\"\n        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1\n        with:\n          persist-credentials: false\n\n      - name: \"Run analysis\"\n        uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3\n        with:\n          results_file: results.sarif\n          results_format: sarif\n          # (Optional) \"write\" PAT token. Uncomment the `repo_token` line below if:\n          # - you want to enable the Branch-Protection check on a *public* repository, or\n          # - you are installing Scorecard on a *private* repository\n          # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.\n          # repo_token: ${{ secrets.SCORECARD_TOKEN }}\n\n          # Public repositories:\n          #   - Publish results to OpenSSF REST API for easy access by consumers\n          #   - Allows the repository to include the Scorecard badge.\n          #   - See https://github.com/ossf/scorecard-action#publishing-results.\n          # For private repositories:\n          #   - `publish_results` will always be set to `false`, regardless\n          #     of the value entered here.\n          publish_results: true\n\n      # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF\n      # format to the repository Actions tab.\n      - name: \"Upload artifact\"\n        uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0\n        with:\n          name: SARIF file\n          path: results.sarif\n          retention-days: 5\n\n      # Upload the results to GitHub's code scanning dashboard.\n      - name: \"Upload to code-scanning\"\n        uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4\n        with:\n          sarif_file: results.sarif\n"
  },
  {
    "path": ".gitignore",
    "content": ".nyc_output/\ncoverage/\nnode_modules/\nnpm-debug.log\npackage-lock.json\n"
  },
  {
    "path": "HISTORY.md",
    "content": "unreleased\n===================\n  * add `:pid` token\n\n1.10.1 / 2025-07-17\n===================\n\n  * deps: on-headers@~1.1.0\n    - 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))\n\n1.10.0 / 2020-03-20\n===================\n\n  * Add `:total-time` token\n  * Fix trailing space in colored status code for `dev` format\n  * deps: basic-auth@~2.0.1\n     - deps: safe-buffer@5.1.2\n  * deps: depd@~2.0.0\n    - Replace internal `eval` usage with `Function` constructor\n    - Use instance methods on `process` to check for listeners\n  * deps: on-headers@~1.0.2\n    - Fix `res.writeHead` patch missing return value\n\n1.9.1 / 2018-09-10\n==================\n\n  * Fix using special characters in format\n  * deps: depd@~1.1.2\n    - perf: remove argument reassignment\n\n1.9.0 / 2017-09-26\n==================\n\n  * Use `res.headersSent` when available\n  * deps: basic-auth@~2.0.0\n     - Use `safe-buffer` for improved Buffer API\n  * deps: debug@2.6.9\n  * deps: depd@~1.1.1\n    - Remove unnecessary `Buffer` loading\n\n1.8.2 / 2017-05-23\n==================\n\n  * deps: debug@2.6.8\n    - Fix `DEBUG_MAX_ARRAY_LENGTH`\n    - deps: ms@2.0.0\n\n1.8.1 / 2017-02-04\n==================\n\n  * deps: debug@2.6.1\n    - Fix deprecation messages in WebStorm and other editors\n    - Undeprecate `DEBUG_FD` set to `1` or `2`\n\n1.8.0 / 2017-02-04\n==================\n\n  * Fix sending unnecessary `undefined` argument to token functions\n  * deps: basic-auth@~1.1.0\n  * deps: debug@2.6.0\n    - Allow colors in workers\n    - Deprecated `DEBUG_FD` environment variable\n    - Fix error when running under React Native\n    - Use same color for same namespace\n    - deps: ms@0.7.2\n  * perf: enable strict mode in compiled functions\n\n1.7.0 / 2016-02-18\n==================\n\n  * Add `digits` argument to `response-time` token\n  * deps: depd@~1.1.0\n    - Enable strict mode in more places\n    - Support web browser loading\n  * deps: on-headers@~1.0.1\n    - perf: enable strict mode\n\n1.6.1 / 2015-07-03\n==================\n\n  * deps: basic-auth@~1.0.3\n\n1.6.0 / 2015-06-12\n==================\n\n  * Add `morgan.compile(format)` export\n  * Do not color 1xx status codes in `dev` format\n  * Fix `response-time` token to not include response latency\n  * Fix `status` token incorrectly displaying before response in `dev` format\n  * Fix token return values to be `undefined` or a string\n  * Improve representation of multiple headers in `req` and `res` tokens\n  * Use `res.getHeader` in `res` token\n  * deps: basic-auth@~1.0.2\n    - perf: enable strict mode\n    - perf: hoist regular expression\n    - perf: parse with regular expressions\n    - perf: remove argument reassignment\n  * deps: on-finished@~2.3.0\n    - Add defined behavior for HTTP `CONNECT` requests\n    - Add defined behavior for HTTP `Upgrade` requests\n    - deps: ee-first@1.1.1\n  * pref: enable strict mode\n  * pref: reduce function closure scopes\n  * pref: remove dynamic compile on every request for `dev` format\n  * pref: remove an argument reassignment\n  * pref: skip function call without `skip` option\n\n1.5.3 / 2015-05-10\n==================\n\n  * deps: basic-auth@~1.0.1\n  * deps: debug@~2.2.0\n    - deps: ms@0.7.1\n  * deps: depd@~1.0.1\n  * deps: on-finished@~2.2.1\n    - Fix `isFinished(req)` when data buffered\n\n1.5.2 / 2015-03-15\n==================\n\n  * deps: debug@~2.1.3\n    - Fix high intensity foreground color for bold\n    - deps: ms@0.7.0\n\n1.5.1 / 2014-12-31\n==================\n\n  * deps: debug@~2.1.1\n  * deps: on-finished@~2.2.0\n\n1.5.0 / 2014-11-06\n==================\n\n  * Add multiple date formats\n    - `clf` for the common log format\n    - `iso` for the common ISO 8601 date time format\n    - `web` for the common RFC 1123 date time format\n  * Deprecate `buffer` option\n  * Fix date format in `common` and `combined` formats\n  * Fix token arguments to accept values with `\"`\n\n1.4.1 / 2014-10-22\n==================\n\n  * deps: on-finished@~2.1.1\n    - Fix handling of pipelined requests\n\n1.4.0 / 2014-10-16\n==================\n\n  * Add `debug` messages\n  * deps: depd@~1.0.0\n\n1.3.2 / 2014-09-27\n==================\n\n  * Fix `req.ip` integration when `immediate: false`\n\n1.3.1 / 2014-09-14\n==================\n\n  * Remove un-used `bytes` dependency\n  * deps: depd@0.4.5\n\n1.3.0 / 2014-09-01\n==================\n\n  * Assert if `format` is not a function or string\n\n1.2.3 / 2014-08-16\n==================\n\n  * deps: on-finished@2.1.0\n\n1.2.2 / 2014-07-27\n==================\n\n  * deps: depd@0.4.4\n    - Work-around v8 generating empty stack traces\n\n1.2.1 / 2014-07-26\n==================\n\n  * deps: depd@0.4.3\n    - Fix exception when global `Error.stackTraceLimit` is too low\n\n1.2.0 / 2014-07-19\n==================\n\n  * Add `:remote-user` token\n  * Add `combined` log format\n  * Add `common` log format\n  * Add `morgan(format, options)` function signature\n  * Deprecate `default` format -- use `combined` format instead\n  * Deprecate not providing a format\n  * Remove non-standard grey color from `dev` format\n\n1.1.1 / 2014-05-20\n==================\n\n  * simplify method to get remote address\n\n1.1.0 / 2014-05-18\n==================\n\n  * \"dev\" format will use same tokens as other formats\n  * `:response-time` token is now empty when immediate used\n  * `:response-time` token is now monotonic\n  * `:response-time` token has precision to 1 μs\n  * fix `:status` + immediate output in node.js 0.8\n  * improve `buffer` option to prevent indefinite event loop holding\n  * deps: bytes@1.0.0\n    - add negative support\n\n1.0.1 / 2014-05-04\n==================\n\n  * Make buffer unique per morgan instance\n  * deps: bytes@0.3.0\n    * added terabyte support\n\n1.0.0 / 2014-02-08\n==================\n\n  * Initial release\n"
  },
  {
    "path": "LICENSE",
    "content": "(The MIT License)\n\nCopyright (c) 2014 Jonathan Ong <me@jongleberry.com>\nCopyright (c) 2014-2017 Douglas Christopher Wilson <doug@somethingdoug.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# morgan\n\n[![NPM Version][npm-version-image]][npm-url]\n[![NPM Downloads][npm-downloads-image]][npm-url]\n[![Build Status][ci-image]][ci-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n\nHTTP request logger middleware for node.js\n\n> Named after [Dexter](http://en.wikipedia.org/wiki/Dexter_Morgan), a show you should not watch until completion.\n\n## Installation\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/). Installation is done using the\n[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```sh\n$ npm install morgan\n```\n\n## API\n\n<!-- eslint-disable no-unused-vars -->\n\n```js\nvar morgan = require('morgan')\n```\n\n### morgan(format, options)\n\nCreate a new morgan logger middleware function using the given `format` and `options`.\nThe `format` argument may be a string of a predefined name (see below for the names),\na string of a format string, or a function that will produce a log entry.\n\nThe `format` function will be called with three arguments `tokens`, `req`, and `res`,\nwhere `tokens` is an object with all defined tokens, `req` is the HTTP request and `res`\nis the HTTP response. The function is expected to return a string that will be the log\nline, or `undefined` / `null` to skip logging.\n\n#### Using a predefined format string\n\n<!-- eslint-disable no-undef -->\n\n```js\nmorgan('tiny')\n```\n\n#### Using format string of predefined tokens\n\n<!-- eslint-disable no-undef -->\n\n```js\nmorgan(':method :url :status :res[content-length] - :response-time ms')\n```\n\n#### Using a custom format function\n\n<!-- eslint-disable no-undef -->\n\n``` js\nmorgan(function (tokens, req, res) {\n  return [\n    tokens.method(req, res),\n    tokens.url(req, res),\n    tokens.status(req, res),\n    tokens.res(req, res, 'content-length'), '-',\n    tokens['response-time'](req, res), 'ms'\n  ].join(' ')\n})\n```\n\n#### Options\n\nMorgan accepts these properties in the options object.\n\n##### immediate\n\nWrite log line on request instead of response. This means that a requests will\nbe logged even if the server crashes, _but data from the response (like the\nresponse code, content length, etc.) cannot be logged_.\n\n##### skip\n\nFunction to determine if logging is skipped, defaults to `false`. This function\nwill be called as `skip(req, res)`.\n\n<!-- eslint-disable no-undef -->\n\n```js\n// EXAMPLE: only log error responses\nmorgan('combined', {\n  skip: function (req, res) { return res.statusCode < 400 }\n})\n```\n\n##### stream\n\nOutput stream for writing log lines, defaults to `process.stdout`.\n\n#### Predefined Formats\n\nThere are various pre-defined formats provided:\n\n##### combined\n\nStandard Apache combined log output.\n```\n:remote-addr - :remote-user [:date[clf]] \":method :url HTTP/:http-version\" :status :res[content-length] \":referrer\" \":user-agent\"\n# will output\n::1 - - [27/Nov/2024:06:21:42 +0000] \"GET /combined HTTP/1.1\" 200 2 \"-\" \"curl/8.7.1\"\n```\n\n##### common\n\nStandard Apache common log output.\n\n```\n:remote-addr - :remote-user [:date[clf]] \":method :url HTTP/:http-version\" :status :res[content-length]\n# will output\n::1 - - [27/Nov/2024:06:21:46 +0000] \"GET /common HTTP/1.1\" 200 2\n```\n\n##### dev\n\nConcise output colored by response status for development use. The `:status`\ntoken will be colored green for success codes, red for server error codes,\nyellow for client error codes, cyan for redirection codes, and uncolored\nfor information codes.\n\n```\n:method :url :status :response-time ms - :res[content-length]\n# will output\nGET /dev 200 0.224 ms - 2\n```\n\n##### short\n\nShorter than default, also including response time.\n\n```\n:remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms\n# will output\n::1 - GET /short HTTP/1.1 200 2 - 0.283 ms\n```\n\n##### tiny\n\nThe minimal output.\n\n```\n:method :url :status :res[content-length] - :response-time ms\n# will output\nGET /tiny 200 2 - 0.188 ms\n```\n\n#### Tokens\n\n##### Creating new tokens\n\nTo define a token, simply invoke `morgan.token()` with the name and a callback function.\nThis callback function is expected to return a string value. The value returned is then\navailable as \":type\" in this case:\n\n<!-- eslint-disable no-undef -->\n\n```js\nmorgan.token('type', function (req, res) { return req.headers['content-type'] })\n```\n\nCalling `morgan.token()` using the same name as an existing token will overwrite that\ntoken definition.\n\nThe token function is expected to be called with the arguments `req` and `res`, representing\nthe HTTP request and HTTP response. Additionally, the token can accept further arguments of\nit's choosing to customize behavior.\n\n##### :date[format]\n\nThe current date and time in UTC. The available formats are:\n\n  - `clf` for the common log format (`\"10/Oct/2000:13:55:36 +0000\"`)\n  - `iso` for the common ISO 8601 date time format (`2000-10-10T13:55:36.000Z`)\n  - `web` for the common RFC 1123 date time format (`Tue, 10 Oct 2000 13:55:36 GMT`)\n\nIf no format is given, then the default is `web`.\n\n##### :http-version\n\nThe HTTP version of the request.\n\n##### :method\n\nThe HTTP method of the request.\n\n##### :pid\n\nThe process ID of the Node.js process handling the request.\n\n##### :referrer\n\nThe Referrer header of the request. This will use the standard mis-spelled Referer header if exists, otherwise Referrer.\n\n##### :remote-addr\n\nThe remote address of the request. This will use `req.ip`, otherwise the standard `req.connection.remoteAddress` value (socket address).\n\n##### :remote-user\n\nThe user authenticated as part of Basic auth for the request.\n\n##### :req[header]\n\nThe given `header` of the request. If the header is not present, the\nvalue will be displayed as `\"-\"` in the log.\n\n##### :res[header]\n\nThe given `header` of the response. If the header is not present, the\nvalue will be displayed as `\"-\"` in the log.\n\n##### :response-time[digits]\n\nThe time between the request coming into `morgan` and when the response\nheaders are written, in milliseconds.\n\nThe `digits` argument is a number that specifies the number of digits to\ninclude on the number, defaulting to `3`, which provides microsecond precision.\n\n##### :status\n\nThe status code of the response.\n\nIf the request/response cycle completes before a response was sent to the\nclient (for example, the TCP socket closed prematurely by a client aborting\nthe request), then the status will be empty (displayed as `\"-\"` in the log).\n\n##### :total-time[digits]\n\nThe time between the request coming into `morgan` and when the response\nhas finished being written out to the connection, in milliseconds.\n\nThe `digits` argument is a number that specifies the number of digits to\ninclude on the number, defaulting to `3`, which provides microsecond precision.\n\n##### :url\n\nThe URL of the request. This will use `req.originalUrl` if exists, otherwise `req.url`.\n\n##### :user-agent\n\nThe contents of the User-Agent header of the request.\n\n### morgan.compile(format)\n\nCompile a format string into a `format` function for use by `morgan`. A format string\nis a string that represents a single log line and can utilize token syntax.\nTokens are references by `:token-name`. If tokens accept arguments, they can\nbe passed using `[]`, for example: `:token-name[pretty]` would pass the string\n`'pretty'` as an argument to the token `token-name`.\n\nThe function returned from `morgan.compile` takes three arguments `tokens`, `req`, and\n`res`, where `tokens` is object with all defined tokens, `req` is the HTTP request and\n`res` is the HTTP response. The function will return a string that will be the log line,\nor `undefined` / `null` to skip logging.\n\nNormally formats are defined using `morgan.format(name, format)`, but for certain\nadvanced uses, this compile function is directly available.\n\n## Examples\n\n### express/connect\n\nSample app that will log all request in the Apache combined format to STDOUT\n\n```js\nvar express = require('express')\nvar morgan = require('morgan')\n\nvar app = express()\n\napp.use(morgan('combined'))\n\napp.get('/', function (req, res) {\n  res.send('hello, world!')\n})\n```\n\n### vanilla http server\n\nSample app that will log all request in the Apache combined format to STDOUT\n\n```js\nvar finalhandler = require('finalhandler')\nvar http = require('http')\nvar morgan = require('morgan')\n\n// create \"middleware\"\nvar logger = morgan('combined')\n\nhttp.createServer(function (req, res) {\n  var done = finalhandler(req, res)\n  logger(req, res, function (err) {\n    if (err) return done(err)\n\n    // respond to request\n    res.setHeader('content-type', 'text/plain')\n    res.end('hello, world!')\n  })\n})\n```\n\n### write logs to a file\n\n#### single file\n\nSample app that will log all requests in the Apache combined format to the file\n`access.log`.\n\n```js\nvar express = require('express')\nvar fs = require('fs')\nvar morgan = require('morgan')\nvar path = require('path')\n\nvar app = express()\n\n// create a write stream (in append mode)\nvar accessLogStream = fs.createWriteStream(path.join(__dirname, 'access.log'), { flags: 'a' })\n\n// setup the logger\napp.use(morgan('combined', { stream: accessLogStream }))\n\napp.get('/', function (req, res) {\n  res.send('hello, world!')\n})\n```\n\n#### log file rotation\n\nSample app that will log all requests in the Apache combined format to one log\nfile per day in the `log/` directory using the\n[rotating-file-stream module](https://www.npmjs.com/package/rotating-file-stream).\n\n```js\nvar express = require('express')\nvar morgan = require('morgan')\nvar path = require('path')\nvar rfs = require('rotating-file-stream') // version 2.x\n\nvar app = express()\n\n// create a rotating write stream\nvar accessLogStream = rfs.createStream('access.log', {\n  interval: '1d', // rotate daily\n  path: path.join(__dirname, 'log')\n})\n\n// setup the logger\napp.use(morgan('combined', { stream: accessLogStream }))\n\napp.get('/', function (req, res) {\n  res.send('hello, world!')\n})\n```\n\n### split / dual logging\n\nThe `morgan` middleware can be used as many times as needed, enabling\ncombinations like:\n\n  * Log entry on request and one on response\n  * Log all requests to file, but errors to console\n  * ... and more!\n\nSample app that will log all requests to a file using Apache format, but\nerror responses are logged to the console:\n\n```js\nvar express = require('express')\nvar fs = require('fs')\nvar morgan = require('morgan')\nvar path = require('path')\n\nvar app = express()\n\n// log only 4xx and 5xx responses to console\napp.use(morgan('dev', {\n  skip: function (req, res) { return res.statusCode < 400 }\n}))\n\n// log all requests to access.log\napp.use(morgan('common', {\n  stream: fs.createWriteStream(path.join(__dirname, 'access.log'), { flags: 'a' })\n}))\n\napp.get('/', function (req, res) {\n  res.send('hello, world!')\n})\n```\n\n### use custom token formats\n\nSample app that will use custom token formats. This adds an ID to all requests and displays it using the `:id` token.\n\n```js\nvar express = require('express')\nvar morgan = require('morgan')\nvar uuid = require('node-uuid')\n\nmorgan.token('id', function getId (req) {\n  return req.id\n})\n\nvar app = express()\n\napp.use(assignId)\napp.use(morgan(':id :method :url :response-time'))\n\napp.get('/', function (req, res) {\n  res.send('hello, world!')\n})\n\nfunction assignId (req, res, next) {\n  req.id = uuid.v4()\n  next()\n}\n```\n\n## License\n\n[MIT](LICENSE)\n\n[ci-image]: https://badgen.net/github/checks/expressjs/morgan/master?label=ci\n[ci-url]: https://github.com/expressjs/morgan/actions/workflows/ci.yml\n[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/morgan/master\n[coveralls-url]: https://coveralls.io/r/expressjs/morgan?branch=master\n[npm-downloads-image]: https://badgen.net/npm/dm/morgan\n[npm-url]: https://npmjs.org/package/morgan\n[npm-version-image]: https://badgen.net/npm/v/morgan\n"
  },
  {
    "path": "index.js",
    "content": "/*!\n * morgan\n * Copyright(c) 2010 Sencha Inc.\n * Copyright(c) 2011 TJ Holowaychuk\n * Copyright(c) 2014 Jonathan Ong\n * Copyright(c) 2014-2017 Douglas Christopher Wilson\n * MIT Licensed\n */\n\n'use strict'\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = morgan\nmodule.exports.compile = compile\nmodule.exports.format = format\nmodule.exports.token = token\n\n/**\n * Module dependencies.\n * @private\n */\n\nvar auth = require('basic-auth')\nvar debug = require('debug')('morgan')\nvar deprecate = require('depd')('morgan')\nvar onFinished = require('on-finished')\nvar onHeaders = require('on-headers')\n\n/**\n * Array of CLF month names.\n * @private\n */\n\nvar CLF_MONTH = [\n  'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',\n  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'\n]\n\n/**\n * Default log buffer duration.\n * @private\n */\n\nvar DEFAULT_BUFFER_DURATION = 1000\n\n/**\n * Create a logger middleware.\n *\n * @public\n * @param {String|Function} format\n * @param {Object} [options]\n * @return {Function} middleware\n */\n\nfunction morgan (format, options) {\n  var fmt = format\n  var opts = options || {}\n\n  if (format && typeof format === 'object') {\n    opts = format\n    fmt = opts.format || 'default'\n\n    // smart deprecation message\n    deprecate('morgan(options): use morgan(' + (typeof fmt === 'string' ? JSON.stringify(fmt) : 'format') + ', options) instead')\n  }\n\n  if (fmt === undefined) {\n    deprecate('undefined format: specify a format')\n  }\n\n  // output on request instead of response\n  var immediate = opts.immediate\n\n  // check if log entry should be skipped\n  var skip = opts.skip || false\n\n  // format function\n  var formatLine = typeof fmt !== 'function'\n    ? getFormatFunction(fmt)\n    : fmt\n\n  // stream\n  var buffer = opts.buffer\n  var stream = opts.stream || process.stdout\n\n  // buffering support\n  if (buffer) {\n    deprecate('buffer option')\n\n    // flush interval\n    var interval = typeof buffer !== 'number'\n      ? DEFAULT_BUFFER_DURATION\n      : buffer\n\n    // swap the stream\n    stream = createBufferStream(stream, interval)\n  }\n\n  return function logger (req, res, next) {\n    // request data\n    req._startAt = undefined\n    req._startTime = undefined\n    req._remoteAddress = getip(req)\n\n    // response data\n    res._startAt = undefined\n    res._startTime = undefined\n\n    // record request start\n    recordStartTime.call(req)\n\n    function logRequest () {\n      if (skip !== false && skip(req, res)) {\n        debug('skip request')\n        return\n      }\n\n      var line = formatLine(morgan, req, res)\n\n      if (line == null) {\n        debug('skip line')\n        return\n      }\n\n      debug('log request')\n      stream.write(line + '\\n')\n    };\n\n    if (immediate) {\n      // immediate log\n      logRequest()\n    } else {\n      // record response start\n      onHeaders(res, recordStartTime)\n\n      // log when response finished\n      onFinished(res, logRequest)\n    }\n\n    next()\n  }\n}\n\n/**\n * Apache combined log format.\n */\n\nmorgan.format('combined', ':remote-addr - :remote-user [:date[clf]] \":method :url HTTP/:http-version\" :status :res[content-length] \":referrer\" \":user-agent\"')\n\n/**\n * Apache common log format.\n */\n\nmorgan.format('common', ':remote-addr - :remote-user [:date[clf]] \":method :url HTTP/:http-version\" :status :res[content-length]')\n\n/**\n * Default format.\n */\n\nmorgan.format('default', ':remote-addr - :remote-user [:date] \":method :url HTTP/:http-version\" :status :res[content-length] \":referrer\" \":user-agent\"')\ndeprecate.property(morgan, 'default', 'default format: use combined format')\n\n/**\n * Short format.\n */\n\nmorgan.format('short', ':remote-addr :remote-user :method :url HTTP/:http-version :status :res[content-length] - :response-time ms')\n\n/**\n * Tiny format.\n */\n\nmorgan.format('tiny', ':method :url :status :res[content-length] - :response-time ms')\n\n/**\n * dev (colored)\n */\n\nmorgan.format('dev', function developmentFormatLine (tokens, req, res) {\n  // get the status code if response written\n  var status = headersSent(res)\n    ? res.statusCode\n    : undefined\n\n  // get status color\n  var color = status >= 500 ? 31 // red\n    : status >= 400 ? 33 // yellow\n      : status >= 300 ? 36 // cyan\n        : status >= 200 ? 32 // green\n          : 0 // no color\n\n  // get colored function\n  var fn = developmentFormatLine[color]\n\n  if (!fn) {\n    // compile\n    fn = developmentFormatLine[color] = compile('\\x1b[0m:method :url \\x1b[' +\n      color + 'm:status\\x1b[0m :response-time ms - :res[content-length]\\x1b[0m')\n  }\n\n  return fn(tokens, req, res)\n})\n\n/**\n * request url\n */\n\nmorgan.token('url', function getUrlToken (req) {\n  return req.originalUrl || req.url\n})\n\n/**\n * request method\n */\n\nmorgan.token('method', function getMethodToken (req) {\n  return req.method\n})\n\n/**\n * response time in milliseconds\n */\n\nmorgan.token('response-time', function getResponseTimeToken (req, res, digits) {\n  if (!req._startAt || !res._startAt) {\n    // missing request and/or response start time\n    return\n  }\n\n  // calculate diff\n  var ms = (res._startAt[0] - req._startAt[0]) * 1e3 +\n    (res._startAt[1] - req._startAt[1]) * 1e-6\n\n  // return truncated value\n  return ms.toFixed(digits === undefined ? 3 : digits)\n})\n\n/**\n * total time in milliseconds\n */\n\nmorgan.token('total-time', function getTotalTimeToken (req, res, digits) {\n  if (!req._startAt || !res._startAt) {\n    // missing request and/or response start time\n    return\n  }\n\n  // time elapsed from request start\n  var elapsed = process.hrtime(req._startAt)\n\n  // cover to milliseconds\n  var ms = (elapsed[0] * 1e3) + (elapsed[1] * 1e-6)\n\n  // return truncated value\n  return ms.toFixed(digits === undefined ? 3 : digits)\n})\n\n/**\n * current date\n */\n\nmorgan.token('date', function getDateToken (req, res, format) {\n  var date = new Date()\n\n  switch (format || 'web') {\n    case 'clf':\n      return clfdate(date)\n    case 'iso':\n      return date.toISOString()\n    case 'web':\n      return date.toUTCString()\n  }\n})\n\n/**\n * response status code\n */\n\nmorgan.token('status', function getStatusToken (req, res) {\n  return headersSent(res)\n    ? String(res.statusCode)\n    : undefined\n})\n\n/**\n * normalized referrer\n */\n\nmorgan.token('referrer', function getReferrerToken (req) {\n  return req.headers.referer || req.headers.referrer\n})\n\n/**\n * remote address\n */\n\nmorgan.token('remote-addr', getip)\n\n/**\n * remote user\n */\n\nmorgan.token('remote-user', function getRemoteUserToken (req) {\n  // parse basic credentials\n  var credentials = auth(req)\n\n  // return username\n  return credentials\n    ? credentials.name\n    : undefined\n})\n\n/**\n * process id\n */\n\nmorgan.token('pid', function getPidToken (req) {\n  return String(process.pid)\n})\n\n/**\n * HTTP version\n */\n\nmorgan.token('http-version', function getHttpVersionToken (req) {\n  return req.httpVersionMajor + '.' + req.httpVersionMinor\n})\n\n/**\n * UA string\n */\n\nmorgan.token('user-agent', function getUserAgentToken (req) {\n  return req.headers['user-agent']\n})\n\n/**\n * request header\n */\n\nmorgan.token('req', function getRequestToken (req, res, field) {\n  // get header\n  var header = req.headers[field.toLowerCase()]\n\n  return Array.isArray(header)\n    ? header.join(', ')\n    : header\n})\n\n/**\n * response header\n */\n\nmorgan.token('res', function getResponseHeader (req, res, field) {\n  if (!headersSent(res)) {\n    return undefined\n  }\n\n  // get header\n  var header = res.getHeader(field)\n\n  return Array.isArray(header)\n    ? header.join(', ')\n    : header\n})\n\n/**\n * Format a Date in the common log format.\n *\n * @private\n * @param {Date} dateTime\n * @return {string}\n */\n\nfunction clfdate (dateTime) {\n  var date = dateTime.getUTCDate()\n  var hour = dateTime.getUTCHours()\n  var mins = dateTime.getUTCMinutes()\n  var secs = dateTime.getUTCSeconds()\n  var year = dateTime.getUTCFullYear()\n\n  var month = CLF_MONTH[dateTime.getUTCMonth()]\n\n  return pad2(date) + '/' + month + '/' + year +\n    ':' + pad2(hour) + ':' + pad2(mins) + ':' + pad2(secs) +\n    ' +0000'\n}\n\n/**\n * Compile a format string into a function.\n *\n * @param {string} format\n * @return {function}\n * @public\n */\n\nfunction compile (format) {\n  if (typeof format !== 'string') {\n    throw new TypeError('argument format must be a string')\n  }\n\n  var fmt = String(JSON.stringify(format))\n  var js = '  \"use strict\"\\n  return ' + fmt.replace(/:([-\\w]{2,})(?:\\[([^\\]]+)\\])?/g, function (_, name, arg) {\n    var tokenArguments = 'req, res'\n    var tokenFunction = 'tokens[' + String(JSON.stringify(name)) + ']'\n\n    if (arg !== undefined) {\n      tokenArguments += ', ' + String(JSON.stringify(arg))\n    }\n\n    return '\" +\\n    (' + tokenFunction + '(' + tokenArguments + ') || \"-\") + \"'\n  })\n\n  // eslint-disable-next-line no-new-func\n  return new Function('tokens, req, res', js)\n}\n\n/**\n * Create a basic buffering stream.\n *\n * @param {object} stream\n * @param {number} interval\n * @public\n */\n\nfunction createBufferStream (stream, interval) {\n  var buf = []\n  var timer = null\n\n  // flush function\n  function flush () {\n    timer = null\n    stream.write(buf.join(''))\n    buf.length = 0\n  }\n\n  // write function\n  function write (str) {\n    if (timer === null) {\n      timer = setTimeout(flush, interval)\n    }\n\n    buf.push(str)\n  }\n\n  // return a minimal \"stream\"\n  return { write: write }\n}\n\n/**\n * Define a format with the given name.\n *\n * @param {string} name\n * @param {string|function} fmt\n * @public\n */\n\nfunction format (name, fmt) {\n  morgan[name] = fmt\n  return this\n}\n\n/**\n * Lookup and compile a named format function.\n *\n * @param {string} name\n * @return {function}\n * @public\n */\n\nfunction getFormatFunction (name) {\n  // lookup format\n  var fmt = morgan[name] || name || morgan.default\n\n  // return compiled format\n  return typeof fmt !== 'function'\n    ? compile(fmt)\n    : fmt\n}\n\n/**\n * Get request IP address.\n *\n * @private\n * @param {IncomingMessage} req\n * @return {string}\n */\n\nfunction getip (req) {\n  return req.ip ||\n    req._remoteAddress ||\n    (req.connection && req.connection.remoteAddress) ||\n    undefined\n}\n\n/**\n * Determine if the response headers have been sent.\n *\n * @param {object} res\n * @returns {boolean}\n * @private\n */\n\nfunction headersSent (res) {\n  // istanbul ignore next: node.js 0.8 support\n  return typeof res.headersSent !== 'boolean'\n    ? Boolean(res._header)\n    : res.headersSent\n}\n\n/**\n * Pad number to two digits.\n *\n * @private\n * @param {number} num\n * @return {string}\n */\n\nfunction pad2 (num) {\n  var str = String(num)\n\n  // istanbul ignore next: num is current datetime\n  return (str.length === 1 ? '0' : '') + str\n}\n\n/**\n * Record the start time.\n * @private\n */\n\nfunction recordStartTime () {\n  this._startAt = process.hrtime()\n  this._startTime = new Date()\n}\n\n/**\n * Define a token function with the given name,\n * and callback fn(req, res).\n *\n * @param {string} name\n * @param {function} fn\n * @public\n */\n\nfunction token (name, fn) {\n  morgan[name] = fn\n  return this\n}\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"morgan\",\n  \"description\": \"HTTP request logger middleware for node.js\",\n  \"version\": \"1.10.1\",\n  \"contributors\": [\n    \"Douglas Christopher Wilson <doug@somethingdoug.com>\",\n    \"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)\"\n  ],\n  \"license\": \"MIT\",\n  \"keywords\": [\n    \"express\",\n    \"http\",\n    \"logger\",\n    \"middleware\"\n  ],\n  \"repository\": \"expressjs/morgan\",\n  \"funding\": {\n    \"type\": \"opencollective\",\n    \"url\": \"https://opencollective.com/express\"\n  },\n  \"dependencies\": {\n    \"basic-auth\": \"~2.0.1\",\n    \"debug\": \"2.6.9\",\n    \"depd\": \"~2.0.0\",\n    \"on-finished\": \"~2.4.1\",\n    \"on-headers\": \"~1.1.0\"\n  },\n  \"devDependencies\": {\n    \"eslint\": \"6.8.0\",\n    \"eslint-config-standard\": \"14.1.1\",\n    \"eslint-plugin-import\": \"2.20.2\",\n    \"eslint-plugin-markdown\": \"1.0.2\",\n    \"eslint-plugin-node\": \"11.1.0\",\n    \"eslint-plugin-promise\": \"4.2.1\",\n    \"eslint-plugin-standard\": \"4.0.1\",\n    \"mocha\": \"10.4.0\",\n    \"nyc\": \"15.1.0\",\n    \"split\": \"1.0.1\",\n    \"supertest\": \"4.0.2\"\n  },\n  \"files\": [\n    \"LICENSE\",\n    \"README.md\",\n    \"index.js\"\n  ],\n  \"engines\": {\n    \"node\": \">= 0.8.0\"\n  },\n  \"scripts\": {\n    \"lint\": \"eslint --plugin markdown --ext js,md .\",\n    \"test\": \"mocha --check-leaks --reporter spec\",\n    \"test-ci\": \"nyc --reporter=lcov --reporter=text npm test\",\n    \"test-cov\": \"nyc --reporter=html --reporter=text npm test\"\n  }\n}\n"
  },
  {
    "path": "test/.eslintrc.yml",
    "content": "env:\n  mocha: true\n"
  },
  {
    "path": "test/fixtures/server.crt",
    "content": "-----BEGIN CERTIFICATE-----\nMIICwDCCAaigAwIBAgIJAJH0k+imlBVmMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNV\nBAMTCWxvY2FsaG9zdDAgFw0xODExMDUwMTM5NThaGA8yMDY4MTAyMzAxMzk1OFow\nFDESMBAGA1UEAxMJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEA3nXOaU7907qgMBLKd4ZuffDPZGN11BmdLCZ68myDVde4N8kzWH7d3ggF\npuqcpGb0sSko7rpf1KHw1p02YEFLRyQigbMfUOSu72BR5aUpxVbG7C87qQ8YWE/8\n3eiImDaDn5tMPnUTwfh0ITCWaW3/4u3PmQB2oJQo7tF5kOMqbY8tDPeO3lX9cx84\nO8BvCchgIPSFthasIRZXnrJicCH0boesA6XNKJbSfoD2hNmUVK8aFeySJ60SdAns\nDNuRJEINy1eEuyHobXleaSZrlQUSPdmqYXkPkrtzHReX63LUnlmxdzn4IZVN79Tu\nYlahulqoIEsaIaAxoGethhNZenytUQIDAQABoxMwETAPBgNVHREECDAGhwR/AAAB\nMA0GCSqGSIb3DQEBCwUAA4IBAQAYLS/7SV+4v3s8KLfOEtCdGw4w7IkBFi3LKKns\nRH74CbDZANJlI/Cc7YuZx2zP/0ux1t2VtVvvMexL4fkQsAsZtLHK5TZq6EzsAIYF\njRXXhkSCfFvxxgj52PxsMD/3tRYZQ8OWyE1f3XL7rwXmeQxOvOuSvafGTXazrSS3\nfmwE53QTLv8Sepf8pTacOY1jQ7pfI4ND3/dOwuO4cc+ulELeCsQq17TEKpL1aXqN\n5gGKe02u9Otq2E39+2FaI11IKUg3EUWKezFlHrxEr32pLPHMq/arVFUOApTgLekB\nUPGac0c4lowHqCXXQBQusihQtnY0JKbzwWnW4UBk5apGSHWR\n-----END CERTIFICATE-----\n"
  },
  {
    "path": "test/fixtures/server.key",
    "content": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDedc5pTv3TuqAw\nEsp3hm598M9kY3XUGZ0sJnrybINV17g3yTNYft3eCAWm6pykZvSxKSjuul/UofDW\nnTZgQUtHJCKBsx9Q5K7vYFHlpSnFVsbsLzupDxhYT/zd6IiYNoOfm0w+dRPB+HQh\nMJZpbf/i7c+ZAHaglCju0XmQ4yptjy0M947eVf1zHzg7wG8JyGAg9IW2FqwhFlee\nsmJwIfRuh6wDpc0oltJ+gPaE2ZRUrxoV7JInrRJ0CewM25EkQg3LV4S7IehteV5p\nJmuVBRI92apheQ+Su3MdF5frctSeWbF3OfghlU3v1O5iVqG6WqggSxohoDGgZ62G\nE1l6fK1RAgMBAAECggEAHKHG/lDXZI/pnCZe/sFDqVv8JWyTtsfRLeSKAHes87h/\nElcID8TMY45ew9wAazyBE+g7R3afbOum5sh3Pi5JNQ/WjSDzz+KPDWo1QDxgwvBn\nS/DMWfcCaCNrZVhPdF/X0wwW5RcGgvmqYLczNMCepaN8C7I+km5fUlWNsvM5+72r\nUwagsYzb4H6FeR5UnXDVoHXhFw/rIgiTqicv6Dg4y177Jev9RPlT9F+RKBVZE1+u\nvB+v66yoN1w2if+wBQICWnqKu0YK+gL31hiFjlbd2SlFcHDl3U41FDdhEk7im13B\n1e400/Fu4MYEmWgGJj82Mm+FBs6jh+CbcjTj4G7trQKBgQD3jswnm9RU21YaNW8N\nmfEXFS8j/cuzJe8Va8swrPh/8L/4L6pdfjrfpA0wXq/SuIiz+xZgszfVlSD1Rf+t\nIcbW71OhahIRglvFRbqk8NYX6uzniWE4IpFBgt9o8HaI8dvfIJNUy3Pc2c6ZgzCc\nZBQbwic65K7VHYVlZ+NANKgN7wKBgQDmC+d9OkPSvOvt7miD5AlUepfHmxDYz9Kf\nUezOqHsI4i8O0cr2PL+HPgOOEsjgB2IIZAcGSV/IqT0Ys4y1KLDU0KMgao//tPFp\n4cN/SxgeaK6WLZP+OAvFi2UXpqUaeCCM/7KaaLoi/WoMqCLJcuJpO8MxsDikg/jp\nrNoOANI4vwKBgQCiBOdAlRAmaVa02HvSHwpW3Rp5J8WFfjI3htD5Dnuk4GADgs6x\nWcgWTjwDiDTyaKuvf4lpyGGme2+Slzl6ijyktwW5Ar7IjtSZC8XX5Xd5N9vMvXDP\nWHBQu+KTv60Ue5Y3Ng621GEEDdjVR7Ms56Lxd+RM+xYhjKydbZyhjNTgKQKBgA9K\nU0Sbjs5/CB90bTX2/jfDPjtiLyh6B8HXLCpAQI1Cm2Ycw6TCPOi8Ungq/3cEhpuQ\nKndcgSVROmJd7MhNwBMlGvKYoqGYYUNsYhYf46aBxrjspp2LFB05OqrrxKWRvngg\ntrpUo6qXtWjJ9CX3oNzlv/+ZeupUa0L83jF4FID5AoGAE3Y42ixUqv86R8ZtK02z\nFA86hT01M2WW7YJyePWQ0/x64Ym3seTzutDFCtEpkAbt+lu/YaCRTz8/NjF0KYzN\nxJ4jjeiccbqslLuVMSfpY7LAm+udn+PsOpL5ezCzwgnFkZAVSKV+VDdENkQCtMaL\nzGVrPC/Lt2tJiLSllgFace0=\n-----END PRIVATE KEY-----\n"
  },
  {
    "path": "test/morgan.js",
    "content": "\nprocess.env.NO_DEPRECATION = 'morgan'\n\nvar assert = require('assert')\nvar fs = require('fs')\nvar http = require('http')\nvar https = require('https')\nvar join = require('path').join\nvar morgan = require('..')\nvar request = require('supertest')\nvar split = require('split')\n\ndescribe('morgan()', function () {\n  describe('arguments', function () {\n    it('should use default format', function (done) {\n      var cb = after(2, function (err, res, line) {\n        if (err) return done(err)\n        assert(res.text.length > 0)\n        assert.strictEqual(line.substr(0, res.text.length), res.text)\n        done()\n      })\n\n      var stream = createLineStream(function (line) {\n        cb(null, null, line)\n      })\n\n      request(createServer(undefined, { stream: stream }))\n        .get('/')\n        .expect(200, cb)\n    })\n\n    describe('format', function () {\n      it('should accept format as format name', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert(/^GET \\/ 200 - - \\d+\\.\\d{3} ms$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('tiny', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should accept format as format string', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'GET /')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':method :url', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should accept format as function', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'GET / 200')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        function format (tokens, req, res) {\n          return [req.method, req.url, res.statusCode].join(' ')\n        }\n\n        request(createServer(format, { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should reject format as bool', function () {\n        assert.throws(createServer.bind(null, true), /argument format/)\n      })\n\n      describe('back-compat', function () {\n        it('should accept options object', function (done) {\n          var cb = after(2, function (err, res, line) {\n            if (err) return done(err)\n            assert(res.text.length > 0)\n            assert.strictEqual(line.substr(0, res.text.length), res.text)\n            done()\n          })\n\n          var stream = createLineStream(function (line) {\n            cb(null, null, line)\n          })\n\n          request(createServer({ stream: stream }))\n            .get('/')\n            .expect(200, cb)\n        })\n\n        it('should accept format in options for back-compat', function (done) {\n          var cb = after(2, function (err, res, line) {\n            if (err) return done(err)\n            assert.strictEqual(line, 'GET /')\n            done()\n          })\n\n          var stream = createLineStream(function (line) {\n            cb(null, null, line)\n          })\n\n          request(createServer({ format: ':method :url', stream: stream }))\n            .get('/')\n            .expect(200, cb)\n        })\n\n        it('should accept format function in options for back-compat', function (done) {\n          var cb = after(2, function (err, res, line) {\n            if (err) return done(err)\n            assert.strictEqual(line, 'apple')\n            done()\n          })\n\n          var stream = createLineStream(function (line) {\n            cb(null, null, line)\n          })\n\n          function format () {\n            return 'apple'\n          }\n\n          request(createServer({ format: format, stream: stream }))\n            .get('/')\n            .expect(200, cb)\n        })\n      })\n    })\n\n    describe('stream', function () {\n      beforeEach(function () {\n        this.stdout = process.stdout\n      })\n\n      afterEach(function () {\n        Object.defineProperty(process, 'stdout', {\n          value: this.stdout\n        })\n      })\n\n      it('should default to process.stdout', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert(res.text.length > 0)\n          assert.strictEqual(line.substr(0, res.text.length), res.text)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        Object.defineProperty(process, 'stdout', {\n          value: stream\n        })\n\n        request(createServer(undefined, { stream: undefined }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should set stream to write logs to', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert(res.text.length > 0)\n          assert.strictEqual(line.substr(0, res.text.length), res.text)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(undefined, { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n    })\n  })\n\n  describe('tokens', function () {\n    describe(':date', function () {\n      it('should get current date in \"web\" format by default', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^\\w{3}, \\d{2} \\w{3} \\d{4} \\d{2}:\\d{2}:\\d{2} GMT$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':date', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should get current date in \"clf\" format', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^\\d{2}\\/\\w{3}\\/\\d{4}:\\d{2}:\\d{2}:\\d{2} \\+0000$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':date[clf]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should get current date in \"iso\" format', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?Z$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':date[iso]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should get current date in \"web\" format', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^\\w{3}, \\d{2} \\w{3} \\d{4} \\d{2}:\\d{2}:\\d{2} GMT$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':date[web]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should be blank for unknown format', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':date[bogus]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':http-version', function () {\n      it('should be 1.0 or 1.1', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^1\\.[01]$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':http-version', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':req', function () {\n      it('should get request properties', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'me')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':req[x-from-string]', { stream: stream }))\n          .get('/')\n          .set('x-from-string', 'me')\n          .expect(200, cb)\n      })\n\n      it('should display all values of array headers', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'foo=bar, fizz=buzz')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':req[set-cookie]', { stream: stream }))\n          .get('/')\n          .set('Set-Cookie', ['foo=bar', 'fizz=buzz'])\n          .expect(200, cb)\n      })\n    })\n\n    describe(':res', function () {\n      it('should get response properties', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'true')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':res[x-sent]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should display all values of array headers', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'foo, bar')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':res[x-keys]', { stream: stream }, function (req, res, next) {\n          res.setHeader('X-Keys', ['foo', 'bar'])\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect('X-Keys', 'foo, bar')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':remote-addr', function () {\n      it('should get remote address', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(res.text.length > 0)\n          assert.strictEqual(line, res.text)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':remote-addr', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should use req.ip if there', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '10.0.0.1')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':remote-addr', { stream: stream }, null, function (req) {\n          req.ip = '10.0.0.1'\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should work on https server', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(res.text.length > 0)\n          assert.strictEqual(line, res.text)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createSecureServer(':remote-addr', { stream: stream })\n\n        request(server)\n          .get('/')\n          .ca(server.cert)\n          .expect(200, cb)\n      })\n\n      it('should work when connection: close', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(res.text.length > 0)\n          assert.strictEqual(line, res.text)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':remote-addr', { stream: stream }))\n          .get('/')\n          .set('Connection', 'close')\n          .expect(200, cb)\n      })\n\n      it('should work when connection: keep-alive', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(res.text.length > 0)\n          assert.strictEqual(line, res.text)\n\n          res.req.connection.destroy()\n          server.close(done)\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':remote-addr', { stream: stream }, function (req, res, next) {\n          delete req._remoteAddress\n          next()\n        })\n\n        request(server.listen())\n          .get('/')\n          .set('Connection', 'keep-alive')\n          .expect(200, cb)\n      })\n\n      it('should work when req.ip is a getter', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '10.0.0.1')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':remote-addr', { stream: stream }, null, function (req) {\n          Object.defineProperty(req, 'ip', {\n            get: function () { return req.connection.remoteAddress ? '10.0.0.1' : undefined }\n          })\n        })\n\n        request(server)\n          .get('/')\n          .set('Connection', 'close')\n          .expect(200, cb)\n      })\n\n      it('should not fail if req.connection missing', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(res.text.length > 0)\n          assert.strictEqual(line, res.text)\n\n          res.req.connection.destroy()\n          server.close(done)\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':remote-addr', { stream: stream }, null, function (req) {\n          delete req.connection\n        })\n\n        request(server.listen())\n          .get('/')\n          .set('Connection', 'keep-alive')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':remote-user', function () {\n      it('should be empty if none present', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':remote-user', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should support Basic authorization', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'tj')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':remote-user', { stream: stream }))\n          .get('/')\n          .set('Authorization', 'Basic dGo6')\n          .expect(200, cb)\n      })\n\n      it('should be empty for empty Basic authorization user', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':remote-user', { stream: stream }))\n          .get('/')\n          .set('Authorization', 'Basic Og==')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':pid', function () {\n      it('should get process id', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, String(process.pid))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':pid', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':response-time', function () {\n      it('should be in milliseconds', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var end = Date.now()\n          var ms = parseFloat(line)\n          assert(ms > 0)\n          assert(ms < end - start + 1)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var start = Date.now()\n\n        request(createServer(':response-time', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should have three digits by default', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^[0-9]+\\.[0-9]{3}$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':response-time', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should have five digits with argument \"5\"', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^[0-9]+\\.[0-9]{5}$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':response-time[5]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should have no digits with argument \"0\"', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^[0-9]+$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':response-time[0]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should not include response write time', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var end = Date.now()\n          var ms = parseFloat(line)\n          assert(ms > 0)\n          assert(ms < end - start + 1)\n          assert(ms < write - start + 1)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':response-time', { stream: stream }, function (req, res) {\n          res.write('hello, ')\n          write = Date.now()\n\n          setTimeout(function () {\n            res.end('world!')\n          }, 50)\n        })\n\n        var start = Date.now()\n        var write = null\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should be empty without hidden property', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':response-time', { stream: stream }, function (req, res, next) {\n          delete req._startAt\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should be empty before response', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':response-time', {\n          immediate: true,\n          stream: stream\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should be empty if morgan invoked after response sent', function (done) {\n        var cb = after(3, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var logger = morgan(':response-time', {\n          immediate: true,\n          stream: stream\n        })\n\n        var server = http.createServer(function (req, res) {\n          setTimeout(function () {\n            logger(req, res, cb)\n          }, 10)\n\n          res.end()\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':status', function () {\n      it('should get response status', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, String(res.statusCode))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':status', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should not exist before response sent', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':status', {\n          immediate: true,\n          stream: stream\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should not exist for aborted request', function (done) {\n        var stream = createLineStream(function (line) {\n          assert.strictEqual(line, '-')\n          server.close(done)\n        })\n\n        var server = createServer(':status', { stream: stream }, function () {\n          test.abort()\n        })\n\n        var test = request(server).post('/')\n        test.write('0')\n      })\n    })\n\n    describe(':total-time', function () {\n      it('should be in milliseconds', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var end = Date.now()\n          var ms = parseFloat(line)\n          assert(ms > 0)\n          assert(ms < end - start + 1)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var start = Date.now()\n\n        request(createServer(':total-time', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should have three digits by default', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^[0-9]+\\.[0-9]{3}$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':total-time', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should have five digits with argument \"5\"', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^[0-9]+\\.[0-9]{5}$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':total-time[5]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should have no digits with argument \"0\"', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.ok(/^[0-9]+$/.test(line))\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':total-time[0]', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should include response write time', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var end = Date.now()\n          var ms = parseFloat(line)\n          assert(ms > 0)\n          assert(ms > write - start - 1)\n          assert(ms < end - start + 1)\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':total-time', { stream: stream }, function (req, res) {\n          res.write('hello, ')\n          write = Date.now()\n\n          setTimeout(function () {\n            res.end('world!')\n          }, 50)\n        })\n\n        var start = Date.now()\n        var write = null\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should be empty without hidden property', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':total-time', { stream: stream }, function (req, res, next) {\n          delete req._startAt\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should be empty before response', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':total-time', {\n          immediate: true,\n          stream: stream\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should be empty if morgan invoked after response sent', function (done) {\n        var cb = after(3, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '-')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var logger = morgan(':total-time', {\n          immediate: true,\n          stream: stream\n        })\n\n        var server = http.createServer(function (req, res) {\n          setTimeout(function () {\n            logger(req, res, cb)\n          }, 10)\n\n          res.end()\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n    })\n\n    describe(':url', function () {\n      it('should get request URL', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '/foo')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':url', { stream: stream }))\n          .get('/foo')\n          .expect(200, cb)\n      })\n\n      it('should use req.originalUrl if exists', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, '/bar')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer(':url', { stream: stream }, function (req, res, next) {\n          req.originalUrl = '/bar'\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should not exist for aborted request', function (done) {\n        var stream = createLineStream(function (line) {\n          assert.strictEqual(line, '-')\n          server.close(done)\n        })\n\n        var server = createServer(':status', { stream: stream }, function () {\n          test.abort()\n        })\n\n        var test = request(server).post('/')\n        test.write('0')\n      })\n    })\n  })\n\n  describe('formats', function () {\n    describe('a function', function () {\n      it('should log result of function', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'GET / 200')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        function format (tokens, req, res) {\n          return [req.method, req.url, res.statusCode].join(' ')\n        }\n\n        request(createServer(format, { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should not log for undefined return', function (done) {\n        var stream = createLineStream(function () {\n          throw new Error('should not log line')\n        })\n\n        function format (tokens, req, res) {\n          return undefined\n        }\n\n        request(createServer(format, { stream: stream }))\n          .get('/')\n          .expect(200, done)\n      })\n\n      it('should not log for null return', function (done) {\n        var stream = createLineStream(function () {\n          throw new Error('should not log line')\n        })\n\n        function format (tokens, req, res) {\n          return null\n        }\n\n        request(createServer(format, { stream: stream }))\n          .get('/')\n          .expect(200, done)\n      })\n    })\n\n    describe('a string', function () {\n      it('should accept format as format string of tokens', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'GET /')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer(':method :url', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should accept text mixed with tokens', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'method=GET url=/')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('method=:method url=:url', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should accept special characters', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line, 'LOCAL\\\\tobi \"GET /\" 200')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('LOCAL\\\\:remote-user \":method :url\" :status', { stream: stream }))\n          .get('/')\n          .set('Authorization', 'Basic dG9iaTpsb2tp')\n          .expect(200, cb)\n      })\n    })\n\n    describe('combined', function () {\n      it('should match expectations', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var masked = line.replace(/\\d{2}\\/\\w{3}\\/\\d{4}:\\d{2}:\\d{2}:\\d{2} \\+0000/, '_timestamp_')\n          assert.strictEqual(masked, res.text + ' - tj [_timestamp_] \"GET / HTTP/1.1\" 200 - \"http://localhost/\" \"my-ua\"')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('combined', { stream: stream }))\n          .get('/')\n          .set('Authorization', 'Basic dGo6')\n          .set('Referer', 'http://localhost/')\n          .set('User-Agent', 'my-ua')\n          .expect(200, cb)\n      })\n    })\n\n    describe('common', function () {\n      it('should match expectations', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var masked = line.replace(/\\d{2}\\/\\w{3}\\/\\d{4}:\\d{2}:\\d{2}:\\d{2} \\+0000/, '_timestamp_')\n          assert.strictEqual(masked, res.text + ' - tj [_timestamp_] \"GET / HTTP/1.1\" 200 -')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('common', { stream: stream }))\n          .get('/')\n          .set('Authorization', 'Basic dGo6')\n          .expect(200, cb)\n      })\n    })\n\n    describe('default', function () {\n      it('should match expectations', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var masked = line.replace(/\\w+, \\d+ \\w+ \\d+ \\d+:\\d+:\\d+ \\w+/, '_timestamp_')\n          assert.strictEqual(masked, res.text + ' - tj [_timestamp_] \"GET / HTTP/1.1\" 200 - \"http://localhost/\" \"my-ua\"')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('default', { stream: stream }))\n          .get('/')\n          .set('Authorization', 'Basic dGo6')\n          .set('Referer', 'http://localhost/')\n          .set('User-Agent', 'my-ua')\n          .expect(200, cb)\n      })\n    })\n\n    describe('dev', function () {\n      it('should not color 1xx', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line.substr(0, 36), '_color_0_GET / _color_0_102_color_0_')\n          assert.strictEqual(line.substr(-9), '_color_0_')\n          done()\n        })\n\n        var stream = createColorLineStream(function onLine (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer('dev', { stream: stream }, function (req, res, next) {\n          res.statusCode = 102\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(102, function (err, res) {\n            if (err && err.code === 'ECONNRESET') {\n              // finishing response with 1xx is invalid http\n              // but node.js server lets the server do this, so\n              // morgan needs to test in this condition even if\n              // the http client doesn't like it\n              err = null\n            }\n            cb(err, res)\n          })\n      })\n\n      it('should color 2xx green', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line.substr(0, 37), '_color_0_GET / _color_32_200_color_0_')\n          assert.strictEqual(line.substr(-9), '_color_0_')\n          done()\n        })\n\n        var stream = createColorLineStream(function onLine (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer('dev', { stream: stream }, function (req, res, next) {\n          res.statusCode = 200\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(200, cb)\n      })\n\n      it('should color 3xx cyan', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line.substr(0, 37), '_color_0_GET / _color_36_300_color_0_')\n          assert.strictEqual(line.substr(-9), '_color_0_')\n          done()\n        })\n\n        var stream = createColorLineStream(function onLine (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer('dev', { stream: stream }, function (req, res, next) {\n          res.statusCode = 300\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(300, cb)\n      })\n\n      it('should color 4xx yelow', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line.substr(0, 37), '_color_0_GET / _color_33_400_color_0_')\n          assert.strictEqual(line.substr(-9), '_color_0_')\n          done()\n        })\n\n        var stream = createColorLineStream(function onLine (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer('dev', { stream: stream }, function (req, res, next) {\n          res.statusCode = 400\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(400, cb)\n      })\n\n      it('should color 5xx red', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          assert.strictEqual(line.substr(0, 37), '_color_0_GET / _color_31_500_color_0_')\n          assert.strictEqual(line.substr(-9), '_color_0_')\n          done()\n        })\n\n        var stream = createColorLineStream(function onLine (line) {\n          cb(null, null, line)\n        })\n\n        var server = createServer('dev', { stream: stream }, function (req, res, next) {\n          res.statusCode = 500\n          next()\n        })\n\n        request(server)\n          .get('/')\n          .expect(500, cb)\n      })\n\n      describe('with \"immediate: true\" option', function () {\n        it('should not have color or response values', function (done) {\n          var cb = after(2, function (err, res, line) {\n            if (err) return done(err)\n            assert.strictEqual(line, '_color_0_GET / _color_0_-_color_0_ - ms - -_color_0_')\n            done()\n          })\n\n          var stream = createColorLineStream(function onLine (line) {\n            cb(null, null, line)\n          })\n\n          var server = createServer('dev', {\n            immediate: true,\n            stream: stream\n          })\n\n          request(server)\n            .get('/')\n            .expect(200, cb)\n        })\n      })\n    })\n\n    describe('short', function () {\n      it('should match expectations', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var masked = line.replace(/\\d+\\.\\d{3} ms/, '_timer_')\n          assert.strictEqual(masked, res.text + ' tj GET / HTTP/1.1 200 - - _timer_')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('short', { stream: stream }))\n          .get('/')\n          .set('Authorization', 'Basic dGo6')\n          .expect(200, cb)\n      })\n    })\n\n    describe('tiny', function () {\n      it('should match expectations', function (done) {\n        var cb = after(2, function (err, res, line) {\n          if (err) return done(err)\n          var masked = line.replace(/\\d+\\.\\d{3} ms/, '_timer_')\n          assert.strictEqual(masked, 'GET / 200 - - _timer_')\n          done()\n        })\n\n        var stream = createLineStream(function (line) {\n          cb(null, null, line)\n        })\n\n        request(createServer('tiny', { stream: stream }))\n          .get('/')\n          .expect(200, cb)\n      })\n    })\n  })\n\n  describe('with buffer option', function () {\n    it('should flush log periodically', function (done) {\n      var cb = after(2, function (err, res, log) {\n        if (err) return done(err)\n        assert.strictEqual(log, 'GET /first\\nGET /second\\n')\n        assert.ok(Date.now() - time >= 1000)\n        assert.ok(Date.now() - time <= 1100)\n        done()\n      })\n      var server = createServer(':method :url', {\n        buffer: true,\n        stream: { write: writeLog }\n      })\n      var time = Date.now()\n\n      function writeLog (log) {\n        cb(null, null, log)\n      }\n\n      request(server)\n        .get('/first')\n        .expect(200, function (err) {\n          if (err) return cb(err)\n          request(server)\n            .get('/second')\n            .expect(200, cb)\n        })\n    })\n\n    it('should not flush before custom interval elapses', function (done) {\n      var writes = []\n      var server = createServer(':method :url', {\n        buffer: 750,\n        stream: { write: function (log) { writes.push(log) } }\n      })\n\n      request(server)\n        .get('/first')\n        .expect(200, function (err) {\n          if (err) return done(err)\n          assert.strictEqual(writes.length, 0)\n\n          request(server)\n            .get('/second')\n            .expect(200, function (err) {\n              if (err) return done(err)\n              assert.strictEqual(writes.length, 0)\n              done()\n            })\n        })\n    })\n  })\n\n  describe('with immediate option', function () {\n    it('should not have value for :res', function (done) {\n      var cb = after(2, function (err, res, line) {\n        if (err) return done(err)\n        assert.strictEqual(line, 'GET / -')\n        done()\n      })\n\n      var stream = createLineStream(function (line) {\n        cb(null, null, line)\n      })\n\n      var server = createServer(':method :url :res[x-sent]', {\n        immediate: true,\n        stream: stream\n      })\n\n      request(server)\n        .get('/')\n        .expect(200, cb)\n    })\n\n    it('should not have value for :response-time', function (done) {\n      var cb = after(2, function (err, res, line) {\n        if (err) return done(err)\n        assert.strictEqual(line, 'GET / -')\n        done()\n      })\n\n      var stream = createLineStream(function (line) {\n        cb(null, null, line)\n      })\n\n      var server = createServer(':method :url :response-time', {\n        immediate: true,\n        stream: stream\n      })\n\n      request(server)\n        .get('/')\n        .expect(200, cb)\n    })\n\n    it('should not have value for :status', function (done) {\n      var cb = after(2, function (err, res, line) {\n        if (err) return done(err)\n        assert.strictEqual(line, 'GET / -')\n        done()\n      })\n\n      var stream = createLineStream(function (line) {\n        cb(null, null, line)\n      })\n\n      var server = createServer(':method :url :status', {\n        immediate: true,\n        stream: stream\n      })\n\n      request(server)\n        .get('/')\n        .expect(200, cb)\n    })\n\n    it('should log before response', function (done) {\n      var lineLogged = false\n      var cb = after(2, function (err, res, line) {\n        if (err) return done(err)\n        assert.strictEqual(line, 'GET / -')\n        done()\n      })\n\n      var stream = createLineStream(function (line) {\n        lineLogged = true\n        cb(null, null, line)\n      })\n\n      var server = createServer(':method :url :res[x-sent]', { immediate: true, stream: stream }, function (req, res, next) {\n        assert.ok(lineLogged)\n        next()\n      })\n\n      request(server)\n        .get('/')\n        .expect(200, cb)\n    })\n  })\n\n  describe('with skip option', function () {\n    it('should be able to skip based on request', function (done) {\n      var stream = createLineStream(function () {\n        throw new Error('should not log line')\n      })\n\n      function skip (req) {\n        return req.url.indexOf('skip=true') !== -1\n      }\n\n      request(createServer({ format: 'default', skip: skip, stream: stream }))\n        .get('/?skip=true')\n        .set('Connection', 'close')\n        .expect(200, done)\n    })\n\n    it('should be able to skip based on response', function (done) {\n      var stream = createLineStream(function () {\n        throw new Error('should not log line')\n      })\n\n      function skip (req, res) {\n        return res.statusCode === 200\n      }\n\n      request(createServer({ format: 'default', skip: skip, stream: stream }))\n        .get('/')\n        .expect(200, done)\n    })\n  })\n})\n\ndescribe('morgan.compile(format)', function () {\n  describe('arguments', function () {\n    describe('format', function () {\n      it('should be required', function () {\n        assert.throws(morgan.compile.bind(morgan), /argument format/)\n      })\n\n      it('should reject functions', function () {\n        assert.throws(morgan.compile.bind(morgan, function () {}), /argument format/)\n      })\n\n      it('should reject numbers', function () {\n        assert.throws(morgan.compile.bind(morgan, 42), /argument format/)\n      })\n\n      it('should compile a string into a function', function () {\n        var fn = morgan.compile(':method')\n        assert.ok(typeof fn === 'function')\n        assert.ok(fn.length === 3)\n      })\n    })\n  })\n})\n\nfunction after (count, callback) {\n  var args = new Array(3)\n  var i = 0\n\n  return function (err, arg1, arg2) {\n    assert.ok(i++ < count, 'callback called ' + count + ' times')\n\n    args[0] = args[0] || err\n    args[1] = args[1] || arg1\n    args[2] = args[2] || arg2\n\n    if (count === i) {\n      callback.apply(null, args)\n    }\n  }\n}\n\nfunction createColorLineStream (callback) {\n  return createLineStream(function onLine (line) {\n    callback(expandColorCharacters(line))\n  })\n}\n\nfunction createLineStream (callback) {\n  return split().on('data', callback)\n}\n\nfunction createRequestListener (format, opts, fn, fn1) {\n  var logger = morgan(format, opts)\n  var middle = fn || noopMiddleware\n\n  return function onRequest (req, res) {\n    // prior alterations\n    if (fn1) {\n      fn1(req, res)\n    }\n\n    logger(req, res, function onNext (err) {\n      // allow req, res alterations\n      middle(req, res, function onDone () {\n        if (err) {\n          res.statusCode = 500\n          res.end(err.message)\n        }\n\n        res.setHeader('X-Sent', 'true')\n        res.end((req.connection && req.connection.remoteAddress) || '-')\n      })\n    })\n  }\n}\n\nfunction createSecureServer (format, opts, fn, fn1) {\n  var cert = fs.readFileSync(join(__dirname, 'fixtures', 'server.crt'), 'ascii')\n  var key = fs.readFileSync(join(__dirname, 'fixtures', 'server.key'), 'ascii')\n\n  return https.createServer({ cert: cert, key: key })\n    .on('request', createRequestListener(format, opts, fn, fn1))\n}\n\nfunction createServer (format, opts, fn, fn1) {\n  return http.createServer()\n    .on('request', createRequestListener(format, opts, fn, fn1))\n}\n\nfunction expandColorCharacters (str) {\n  // eslint-disable-next-line no-control-regex\n  return str.replace(/\\x1b\\[(\\d+)m/g, '_color_$1_')\n}\n\nfunction noopMiddleware (req, res, next) {\n  next()\n}\n"
  }
]