Permalink
Browse files

expose the parser and upgrade()

  • Loading branch information...
1 parent a46cdaa commit c1e2b868aa06ecb7cf1b2d3d022b9d8234646bac @substack committed Feb 13, 2012
Showing with 10 additions and 7 deletions.
  1. +2 −2 README.markdown
  2. +7 −4 index.js
  3. +1 −1 package.json
View
@@ -9,6 +9,8 @@ with the simple command-line tool.
Bouncy is websocket and tls (https) capable.
+[![build status](https://secure.travis-ci.org/substack/bouncy.png)](http://travis-ci.org/substack/bouncy)
+
![trampoline](http://substack.net/images/trampoline.png)
example
@@ -143,5 +145,3 @@ tests
With [npm](http://npmjs.org), do:
npm test
-
-[![build status](https://secure.travis-ci.org/substack/bouncy.png)](http://travis-ci.org/substack/bouncy)
View
@@ -25,7 +25,7 @@ var bouncy = module.exports = function (opts, cb) {
};
var handler = bouncy.handler = function (cb, c) {
- parsley(c, function (req) {
+ var parser = parsley(c, function (req) {
c.setMaxListeners(0);
var stream = new BufferedStream;
@@ -51,22 +51,22 @@ var handler = bouncy.handler = function (cb, c) {
req.removeListener('error', onError);
// don't kill the server on subsequent request errors
req.on('error', function () {});
- var bounce = makeBounce(stream, c, req);
+ var bounce = makeBounce(stream, c, req, parser);
cb(req, bounce);
}
req.on('headers', onHeaders);
function onError (err) {
req.removeListener('headers', onHeaders);
- var bounce = makeBounce(stream, c, req);
+ var bounce = makeBounce(stream, c, req, parser);
cb(req, bounce);
req.emit('error', err);
}
req.once('error', onError);
});
};
-function makeBounce (bs, client, req) {
+function makeBounce (bs, client, req, parser) {
var bounce = function (stream, opts) {
if (!stream || !stream.write) {
opts = parseArgs(arguments);
@@ -109,6 +109,9 @@ function makeBounce (bs, client, req) {
return stream;
};
+ bounce.parser = parser;
+ bounce.upgrade = parser.upgrade.bind(parser);
+
bounce.respond = function () {
var res = new ServerResponse(req);
res.assignSocket(client);
View
@@ -30,7 +30,7 @@
"test" : "tap test/*.js"
},
"dependencies" : {
- "parsley" : "0.0.x",
+ "parsley" : "0.1.x",
"morestreams" : "0.0.2"
},
"devDependencies" : {

0 comments on commit c1e2b86

Please sign in to comment.