{"_id":"express-hijackresponse","_rev":"33-5df94193755f42873e40bdd9913df2c7","name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","dist-tags":{"latest":"0.2.1"},"versions":{"0.0.1":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.0.1","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"papandreou","email":"andreas@one.com"},"_id":"express-hijackresponse@0.0.1","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"622c4024df3e5745b15f73e308ad1db25e30df70","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.0.1.tgz","integrity":"sha512-ng2aJEpRJq7UDlpDia9CvkzdEqtv4p2QOwrTbvhBNNgUutRiZkEhIAEfQuNhYKAm52DnAjkXO5hupC00aGCByA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDdHc9bGDHJqMtTwiaRyKBh/bju+kXS5tEWFEfKgHuTcAiB7xmMxl4NtcyMC4EgL8q1wU8zPeo4Ivulmx+rYb21laQ=="}]},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}],"directories":{}},"0.0.2":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.0.2","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"papandreou","email":"andreas@one.com"},"_id":"express-hijackresponse@0.0.2","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"34932e6238d91fcdddf22dd8a0cacdb5c6c05b53","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.0.2.tgz","integrity":"sha512-w1kuPQKyt/m5pOnUuNEClAFQ901Zjhwe0b2UJ4V9mwQJxt7HvYJIFKMqVtI3lsNVOjDERMIy/btnYJgsyVo0iw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCk7j2l96r5J82aiSjM4zi9F6xi9PJ3FutuGZ3MKjkDBgIgDL08/hQ2T4axwmxkKLr+8cPDWFsZVaj7JyCKGCzglbs="}]},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}],"directories":{}},"0.0.3":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.0.3","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"papandreou","email":"andreas@one.com"},"_id":"express-hijackresponse@0.0.3","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"354be9adbe603bbc881173a91a7b78f5f0905a73","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.0.3.tgz","integrity":"sha512-LXLCa4FDYuHkLlKKLbbyu15jY8GHPbhvwMKIVxRZzg/vaBG5AUcClP9QO8XR/6Pfn1QXEm74fQK7mijZrqCaaw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkd4xJE9+DGHOodqewV1f+4AB75boq0o+aXuN7kIHCqgIhALoYKKaM/E/CC7tVJIyHaXR+cksZ6j7UMEEwLqe03i6s"}]},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}],"directories":{}},"0.0.4":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.0.4","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{},"_npmUser":{"name":"papandreou","email":"andreas@one.com"},"_id":"express-hijackresponse@0.0.4","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"e40ad7efd87198f9f3e0afd0389a38eba96307d4","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.0.4.tgz","integrity":"sha512-mQrWEaOJwixloFpFAWtQ29XeK4nG90SxgFJk2tt1aExVqFBJcPiL/muSokrcJB6CoiVJYk5Q2EgjsbFlLU0wcQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGhQ/CaE54ybzWaVhwwgOKORAismm4Tv1CYTnNfsp+ofAiAZ04loRr7Bp4Sz+oPiQmnJlMvOFsejqb6y9rk/PlU+4w=="}]},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}],"directories":{}},"0.0.6":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.0.6","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{"express":"= 2.5.8","request":"= 2.9.153","vows":"= 0.6.2"},"_npmUser":{"name":"papandreou","email":"andreas@one.com"},"_id":"express-hijackresponse@0.0.6","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"6b2f0b1859301c6436eecb067691302c2a173d57","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.0.6.tgz","integrity":"sha512-mpKjLYTW7BKyNJBLNEChTwb29CI5c0pwPAn7n7V+hdXELdeg0/hD63YRLsasqS0mq8oE5LBb7NzIUC58072Fqw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG2uo7fp2PcFGNv+7oirYicZqEeX7pkQj0ICGBf7GQtAAiA0ikbjQNK2ru18CNP8pU3GWA+UdgTOcow66j08ev/HvQ=="}]},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}],"directories":{}},"0.0.5":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.0.5","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{"express":"= 2.5.8","request":"= 2.9.153","vows":"= 0.6.2"},"_npmUser":{"name":"papandreou","email":"andreas@one.com"},"_id":"express-hijackresponse@0.0.5","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"cb60821c652a3d7328ac446738cc284239aec293","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.0.5.tgz","integrity":"sha512-AuZ8L+pUeea3z834iZWiNDw7H0WtTkSwLifTy/HatA8owHIuOnVnFEo5lX42hDRDQqIRlyHaknjcBV6zs4FXEA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAS6kveylt64/gnXng3RLLKry9el+EDcPxWk3jpgUqCNAiEA5oU16XdpKKbBh9wNYlq7wAsGDT4SGsP6+wfHS5IFhkk="}]},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}]},"0.0.7":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.0.7","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">= 0.4.0"},"dependencies":{},"devDependencies":{"bufferedstream":"= 1.0.1","express":"= 2.5.8","request":"= 2.9.153","vows":"= 0.6.2"},"_npmUser":{"name":"papandreou","email":"andreas@one.com"},"_id":"express-hijackresponse@0.0.7","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.13-pre","_defaultsLoaded":true,"dist":{"shasum":"5299aa1458113501ed4a7650ab4f5916d456ca05","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.0.7.tgz","integrity":"sha512-D6X/iw+1+lqaP0mye5ObbaRMXUThJkqk6YjKrsX8xMneDcuuHgkrRwIHFBv2KVlAW3RIrfDWpK4fqJl3gvH+mg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEE4/ob/ZxwralvRyr/43RL+SdA3DAoR7SA6Lzoq4XHjAiBiGJDIDSS6H7eV2akee2bxo3WGCxM+H1Ofh8gXv6eKmg=="}]},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}]},"0.1.0":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.1.0","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">=0.4.0"},"dependencies":{},"devDependencies":{"bufferedstream":"=1.0.1","express":"=2.5.11","request":"=2.9.153","vows":"=0.6.2"},"_id":"express-hijackresponse@0.1.0","dist":{"shasum":"fa8b3db0d085e487ae1620800404627983668072","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.1.0.tgz","integrity":"sha512-zFfGyY+JVibzk5csklm1ALqDTiINz3KQhz9YvvH4LQGH1feiB6+KyjotkJdGtjosg+Ou4Ay86QZTkVSJT84POg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7PtnQi70qPSS/GF02RXU5sVUFuRLZWZ8nUPagUl7shQIhAO3cHzPh8ZqjyOpzQZZehJXL5hfIOPWVqQ2aDcHohYWr"}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"papandreou","email":"andreas@one.com"},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}]},"0.1.1":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.1.1","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">=0.4.0"},"dependencies":{},"devDependencies":{"bufferedstream":"=1.0.1","express":"=2.5.11","request":"=2.9.153","vows":"=0.6.2"},"_id":"express-hijackresponse@0.1.1","dist":{"shasum":"7bf21b079035abca9a06bf94c1db31b18e1af61a","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.1.1.tgz","integrity":"sha512-HC1iBY5g31YbUbA7wq2uz1ve4I2cwHNYwFfKrWSbbLqI3t/DmZhzBZs9KO+Ut0Dr9qg5BDB6ldbKdBghQOX+/A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD3Zy33kQ5Fgupd2I/MijGicIAdEJvA0OIWEDkMRTcy6AIgapkVZ36NROMds6AZEgIHbXWfzJmWZhmMLDeDD3XUoCg="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"papandreou","email":"andreas@one.com"},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}]},"0.1.2":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.1.2","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/index.js","engines":{"node":">=0.4.0"},"dependencies":{},"devDependencies":{"bufferedstream":"=1.0.1","express":"=2.5.11","request":"=2.9.153","vows":"=0.6.2"},"_id":"express-hijackresponse@0.1.2","dist":{"shasum":"f37efb6c149a26fe4051fb6558a6bd31d8a2b3d5","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.1.2.tgz","integrity":"sha512-8pNCYV3rIuokiwxbeyQbCQkB0oaUiAlMaRs+EmAuGOHdxwh86SjMoytKafAGFKTJQkYo2DccxpwOPpX3khjk8g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDGlwdPtkp9muhK5u35X51tddAuQuHtncLMBjz22tlj4AIhAOZPByS6ST9gTvddTmm1lSFFmQpL/PkBqmcU6yD0SN8w"}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"papandreou","email":"andreas@one.com"},"maintainers":[{"name":"papandreou","email":"andreas@one.com"}]},"0.2.1":{"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"name":"express-hijackresponse","description":"Rewrite HTTP responses on their way out.","version":"0.2.1","repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"main":"lib/hijackResponse.js","engines":{"node":">=0.10.0"},"devDependencies":{"bufferedstream":"=1.0.1","express":"4.8.8","request":"=2.9.153","vows":"0.7.0"},"gitHead":"3ce9ce337ecee0261b04ae38ba5a6a734b1f4669","bugs":{"url":"https://github.com/papandreou/express-hijackresponse/issues"},"homepage":"https://github.com/papandreou/express-hijackresponse","_id":"express-hijackresponse@0.2.1","scripts":{},"_shasum":"1aa2ce09920e05f8141df800408c27bee9386b92","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"maartenwinter","email":"maarten@mwinter.nl"},"maintainers":[{"name":"papandreou","email":"andreas@one.com"},{"name":"maartenwinter","email":"maarten@mwinter.nl"}],"dist":{"shasum":"1aa2ce09920e05f8141df800408c27bee9386b92","tarball":"https://registry.npmjs.org/express-hijackresponse/-/express-hijackresponse-0.2.1.tgz","integrity":"sha512-vOLI1F4pXB2Vkzk88QnGgYVXZw9mJqFtTemXS2jawHTLaWvJdDeclh+dx9AMnsK2YNJcl+cWTGpoHLBnF+1FTQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDezkIhdfu3iqcXoYtmm1U9cvETQTJr5Ny0vYjrO6bupAIhAIo05aU4A5Q34OY/j+6LvgSiyGKET8ayLfqdMdlw7reK"}]}}},"readme":"express-hijackresponse\n======================\n\nModule that allows you to rewrite HTTP responses from middleware\nfurther down the stack, such as static providers, HTTP proxies etc.\n\nIt's mostly useful for content filters. The original use case is\ninjecting an inline JavaScript into all HTML responses in <a\nhref='https://github.com/One-com/livestyle'>LiveStyle</a>.\n\n\nInstallation\n------------\n\nMake sure you have node.js and npm installed, then run:\n\n    npm install express-hijackresponse\n\nUsage\n-----\n\nRequiring the module installs a `hijack` method on your response objects:\n\n    var express = require('express');\n    require('express-hijackresponse');\n\n    var app = express.createServer();\n\n    // ...\n\n    app.use(function (req, res, next) {\n        res.hijack(function (err, res) {\n            if (err) {\n                res.unhijack(); // Make the original res object work again\n                return next(err);\n            }\n            // 'res' is now a fake response object with `writeHead`,\n            // `write`, `end`, `getHeader`, `setHeader`, `removeHeader` methods.\n\n            if (/^text/html(?:;$)/.test(res.getHeader('Content-Type'))) {\n                // Don't hijack HTML responses:\n                return res.unhijack();\n            }\n            res.setHeader('X-Hijacked', 'yes!');\n            res.removeHeader('Content-Length');\n\n            // It emits 'data' and 'end' events representing the original response:\n            res.on('data', function (chunk, encoding) {\n                // The original response emitted a chunk!\n            }).on('end', function () {\n                // The original response ended!\n                res.end('Sorry, your data was hijacked!');\n            });\n        });\n        // next() must be called explicitly, even when hijacking the response:\n        next();\n    });\n\n\nExample\n-------\n\nRewrite all JSON responses so they're wrapped into a {\"foo\": ...} literal:\n\n    var express = require('express');\n    require('express-hijackresponse');\n\n    express.createServer()\n        .use(function (req, res, next) {\n            if (req.accepts('json')) {\n                res.hijack(function (err, res) {\n                    if (err) {\n                        res.unhijack(); // Make the original res object work again\n                        return next(err);\n                    }\n                    // Inspect the original response headers to see if we actually want to rewrite the response:\n                    if (/\\/json$/.test(res.getHeader('Content-Type'))) {\n                        // Remove Content-Length if it's there (it won't be correct when the response has been rewritten):\n                        res.removeHeader('Content-Length');\n                        res.writeHead(res.statusCode);\n                        res.write('{\"foo\":');\n\n                        // Stream the original response and slip in a '}' before ending:\n                        res.pipe(res, {end: false});\n                        res.on('end', function () {\n                            res.write('}');\n                            res.end();\n                        });\n                    } else {\n                        res.unhijack();\n                    }\n                });\n            }\n            next();\n        })\n        .use(express.static(__dirname))\n        .listen(1337);\n\nTODO\n----\n\nBetter error handling, backpressure support when streaming.\n\n\nLicense\n-------\n\n3-clause BSD license -- see the `LICENSE` file for details.\n","maintainers":[{"email":"andreas@one.com","name":"papandreou"},{"email":"mail@mwinter.nl","name":"maartenwinter"}],"time":{"modified":"2022-06-17T22:20:15.232Z","created":"2012-03-07T00:01:12.619Z","0.0.1":"2012-03-07T00:01:14.131Z","0.0.2":"2012-03-07T16:28:43.946Z","0.0.3":"2012-03-07T22:11:34.107Z","0.0.4":"2012-03-07T23:49:35.792Z","0.0.5":"2012-03-12T09:06:28.161Z","0.0.6":"2012-03-11T12:40:23.894Z","0.0.7":"2012-03-13T23:44:40.105Z","0.1.0":"2013-03-12T17:02:18.762Z","0.1.1":"2013-03-19T12:36:29.969Z","0.1.2":"2013-03-26T12:56:45.591Z","0.2.1":"2014-10-13T09:38:17.156Z"},"author":{"name":"Andreas Lind Petersen","email":"andreas@one.com"},"repository":{"type":"git","url":"git://github.com/papandreou/express-hijackresponse.git"},"readmeFilename":"README.md","homepage":"https://github.com/papandreou/express-hijackresponse","bugs":{"url":"https://github.com/papandreou/express-hijackresponse/issues"},"users":{}}