{"name":"http-raw","version":"0.0.2","description":"expose the raw request data in an http server","main":"index.js","directories":{"example":"example","test":"test"},"dependencies":{},"devDependencies":{"tap":"~0.3.0","through":"~2.1.0"},"scripts":{"test":"tap test/*.js"},"repository":{"type":"git","url":"git://github.com/substack/http-raw.git"},"homepage":"https://github.com/substack/http-raw","keywords":["http","raw","server","proxy"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"license":"MIT","readme":"# http-raw\n\nexpose the raw request data in an http server\n\n[![build status](https://secure.travis-ci.org/substack/http-raw.png)](http://travis-ci.org/substack/http-raw)\n\n# example\n\n``` js\nvar createServer = require('http-raw');\nvar through = require('through');\n\nvar server = createServer(function (req, res) {\n    if (req.method === 'GET') {\n        res.end('beep boop\\n');\n    }\n    else {\n        var bs = req.createRawBodyStream();\n        bs.write('HTTP/1.1 200 OK\\r\\n\\r\\n');\n        bs.pipe(upper()).pipe(bs)\n    }\n});\nserver.listen(7000);\n\nfunction upper () {\n    return through(function (buf) {\n        this.emit('data', String(buf).toUpperCase());\n    });\n}\n```\n\n```\n$ node example/server.js &\n$ nc localhost 7000\nPUT / HTTP/1.1\nHost: robots\n\nHTTP/1.1 200 OK\n\n\nbeep \nBEEP\nboop\nBOOP\n```\n\n# methods\n\n``` js\nvar createServer = require('http-raw')\n```\n\nThe http-raw api is exactly like the `http.createServer(cb)` api from core,\nexcept that 2 extra functions are available on the `req` objects from the\n`cb(req,res)` handler:\n\n## var s = req.createRawStream()\n\nReturn a readable/writable stream `s`. `s` will emit all the raw data from the\nconnection, including the buffered header data without doing any parsing on the\ndata beforehand.\n\nWriting to `s` goes through to the underlying network socket without any\nadditional framing applied.\n\nTo get all the data, `req.createRawStream()` must be fired on the same tick as\nthe response callback.\n\nOn the same tick as the response handler, `s.buffers` will have all all the\nbuffer slices formatted as an array where each element is an array:\n\n``` js\n[ buffer, start, end ]\n```\n\nOn the next tick `s.buffers` gets set to undefined to it can be garbage\ncollected.\n\n## var s = req.createRawBodyStream()\n\nReturn a readable/writable stream `s`. `s` will emit the raw data from after the\nheaders have been parsed, including any framing without doing any parsing.\n\nWriting to `s` goes through to the underlying network socket without any\nadditional framing applied.\n\nTo get all the data, `req.createRawBodyStream()` must be fired on the same tick\nas the response callback.\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install http-raw\n```\n\n# license\n\nMIT\n","_id":"http-raw@0.0.2","dist":{"shasum":"35109da445a032fafb632296d3150f47afa9bd42","tarball":"http://registry-npm.ywwl.com/http-raw/download/http-raw-0.0.2.tgz","integrity":"sha512-+XGMAGsgA7zBWPZmbNt4evRoxGogkVszZaHUMBXEZiCMou0wnoodp37HebLS1NYco8wmqG0E0xtzDGjkszgVyQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAr0T7Ux8Gi9oo1tiwLkp9BoZwvu+ZJ8h5VWaCJWqHweAiEAg9s+Osmo5G7fUSpIRtzBJtm9b+13R2T87Jt2NO68eXc="}],"size":3902,"noattachment":false,"key":"/http-raw/-/http-raw-0.0.2.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"substack","email":"mail@substack.net"},"maintainers":[{"name":"substack","email":"mail@substack.net"}],"publish_time":1355540959006,"_cnpm_publish_time":1355540959006,"dist-tags":{"latest":"2.1.0"}}