{"name":"request-debug","author":{"name":"James Nylen","email":"jnylen@gmail.com"},"description":"Library to assist with debugging HTTP(s) requests made by the request module.","version":"0.2.0","repository":{"type":"git","url":"https://github.com/request/request-debug"},"bugs":{"url":"https://github.com/request/request-debug/issues"},"license":"MIT","keywords":["request","debug","http","https","headers"],"scripts":{"test":"node node_modules/.bin/mocha"},"main":"index.js","devDependencies":{"detect-engine":"~1.0.2","express":"~4.8.6","mocha":"~1.21.4","passport":"~0.2.0","passport-http":"~0.2.2","request":"~2.50.0","should":"~4.0.4"},"dependencies":{"stringify-clone":"^1.0.0"},"gitHead":"afd2d830582ee6d86a7d14b3490e0a2eb80068da","homepage":"https://github.com/request/request-debug","_id":"request-debug@0.2.0","_shasum":"fc054ec817181b04ca41a052c136f61c48abaf78","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"simov","email":"simeonvelichkov@gmail.com"},"maintainers":[{"name":"nylen","email":"jnylen@gmail.com"},{"name":"simov","email":"simeonvelichkov@gmail.com"}],"dist":{"shasum":"fc054ec817181b04ca41a052c136f61c48abaf78","tarball":"http://registry-npm.ywwl.com/request-debug/download/request-debug-0.2.0.tgz","integrity":"sha512-NWYi/Gz4xKSkK1oPAsLLjMkSbp4aaW77fxPGe7uoKg1bgN7qXKVI5S/Cm/cubTKD62yJd7eKQLdlQ9QRLhgvvA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCeY6UHYCZkdyeQEitVesOb8F+wQbrtRM26k4rUJA/s0AIhAJA9dZZiW9OpnDVuecsKX3nEc41nCem88G742tBCRksY"}],"size":8433,"noattachment":false,"key":"/request-debug/-/request-debug-0.2.0.tgz"},"directories":{},"readme":"# request-debug [![Build status](https://img.shields.io/travis/request/request-debug.svg?style=flat)](https://travis-ci.org/request/request-debug) [![npm package](http://img.shields.io/npm/v/request-debug.svg?style=flat)](https://www.npmjs.org/package/request-debug)\n\nThis Node.js module provides an easy way to monitor HTTP(S) requests performed\nby the [`request` module](https://github.com/request/request), and their\nresponses from external servers.\n\n## Usage\n\nBasic usage is to require the module and call it, passing in the object\nreturned by `require('request')`:\n\n```js\nvar request = require('request');\n\nrequire('request-debug')(request);\n```\n\nThis will set up event handlers on every request performed with the `request`\nvariable from this point.\n\nYou can also specify a function to handle request or response data:\n\n```js\nrequire('request-debug')(request, function(type, data, r) {\n    // put your request or response handling logic here\n});\n```\n\nIf you specify your own handling function, `r` will be the `Request` instance\nthat generated the event, and `type` will be one of the following values:\n\n- **request** - Headers were sent to the server and will be included as\n  `data.headers`.  `data.body` may also be present for POST requests.\n\n- **response** - Headers were received from the server and will be included as\n  `data.headers`.  Note that `request` only buffers the response body if a\n  callback was given, so it will only be available as `data.body` if the\n  initial call to `request` included a callback.\n\n- **redirect** - A redirect status code (*HTTP 3xx*) was received.  The `data`\n  object will have properties `statusCode`, `headers`, and `uri` (the address\n  of the next request).\n\n- **auth** - A *HTTP 401 Unathorized* response was received.  Internally,\n  `request` handles this like a redirect, so the same properties will be\n  available on the `data` object.\n\nYou can use the `data.debugId` parameter to match up requests with their\nresponses and other events.\n\nThe default handling function writes the data to *stderr* in Node's JSON-like\nobject display format.  See the example below for more details.\n\nTo disable debugging, call `request.stopDebugging()` (this function only exists\nif debugging has already been enabled).  Any requests that are in progress when\n`stopDebugging()` is called will still generate debug events.\n\n## Example\n\n```js\nvar request = require('request');\n\nrequire('request-debug')(request);\n\n// digest.php is example 2 from:\n// http://php.net/manual/en/features.http-auth.php\n\nrequest({\n    uri  : 'http://nylen.tv/digest.php',\n    auth : {\n        user : 'admin',\n        pass : 'mypass',\n        sendImmediately : false\n    },\n    rejectUnauthorized : false,\n}, function(err, res, body) {\n    console.log('REQUEST RESULTS:', err, res.statusCode, body);\n});\n```\n\nUnless you provide your own function as the second parameter to the\n`request-debug` call, this will produce console output similar to the\nfollowing:\n\n```js\n{ request:\n   { debugId: 1,\n     uri: 'http://nylen.tv/digest.php',\n     method: 'GET',\n     headers: { host: 'nylen.tv' } } }\n{ auth:\n   { debugId: 1,\n     statusCode: 401,\n     headers:\n      { date: 'Mon, 20 Oct 2014 03:34:58 GMT',\n        server: 'Apache/2.4.6 (Debian)',\n        'x-powered-by': 'PHP/5.5.6-1',\n        'www-authenticate': 'Digest realm=\"Restricted area\",qop=\"auth\",nonce=\"544482e2556d9\",opaque=\"cdce8a5c95a1427d74df7acbf41c9ce0\"',\n        'content-length': '39',\n        'keep-alive': 'timeout=5, max=100',\n        connection: 'Keep-Alive',\n        'content-type': 'text/html' },\n     uri: 'http://nylen.tv/digest.php' } }\n{ request:\n   { debugId: 1,\n     uri: 'http://nylen.tv/digest.php',\n     method: 'GET',\n     headers:\n      { authorization: 'Digest username=\"admin\", realm=\"Restricted area\", nonce=\"544482e2556d9\", uri=\"/digest.php\", qop=auth, response=\"e833c7fa52e8d42fae3ca784b96dfd38\", nc=00000001, cnonce=\"ab6ff3dd95a0449e990a6c8465a6bb26\", opaque=\"cdce8a5c95a1427d74df7acbf41c9ce0\"',\n        host: 'nylen.tv' } } }\n{ response:\n   { debugId: 1,\n     headers:\n      { date: 'Mon, 20 Oct 2014 03:34:58 GMT',\n        server: 'Apache/2.4.6 (Debian)',\n        'x-powered-by': 'PHP/5.5.6-1',\n        'content-length': '27',\n        'keep-alive': 'timeout=5, max=100',\n        connection: 'Keep-Alive',\n        'content-type': 'text/html' },\n     statusCode: 200,\n     body: 'You are logged in as: admin' } }\nREQUEST RESULTS: null 200 You are logged in as: admin\n```\n\n## Compatibility\n\nTested with Node.js versions 0.8.x, 0.10.x, and 0.11.x on Travis, and a bunch\nof different `request` versions.\n\nDoes not work with `request` versions older than 2.22.0 (July 2013).  Tests\ndon't start passing until version 2.28.0 (December 2013).\n","publish_time":1432144637448,"_cnpm_publish_time":1432144637448,"dist-tags":{"latest":"0.2.0"}}