diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index f90eb3c2c7b..972e2bad892 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -81,17 +81,18 @@ static Persistent should_keep_alive_sym; HandleScope scope; \ \ assert(parser->buffer_); \ - char * base = buffer_p(parser->buffer_, 0); \ + struct buffer * root = buffer_root(parser->buffer_); \ + char * base = buffer_p(root, 0); \ \ Local cb_value = parser->handle_->Get(name##_sym); \ if (!cb_value->IsFunction()) return 0; \ Local cb = Local::Cast(cb_value); \ \ - Local off = Integer::New(at - base); \ - Local len = Integer::New(length); \ - Local argv[2] = { off, len }; \ - \ - Local ret = cb->Call(parser->handle_, 2, argv); \ + Local argv[3] = { Local::New(root->handle) \ + , Integer::New(at - base) \ + , Integer::New(length) \ + }; \ + Local ret = cb->Call(parser->handle_, 3, argv); \ return ret.IsEmpty() ? -1 : 0; \ } diff --git a/test/mjsunit/test-http-parser.js b/test/mjsunit/test-http-parser.js index fa6ac6e5928..db148c7c118 100644 --- a/test/mjsunit/test-http-parser.js +++ b/test/mjsunit/test-http-parser.js @@ -29,14 +29,14 @@ parser.onHeadersComplete = function (info) { callbacks++; }; -parser.onURL = function (off, len) { +parser.onURL = function (b, off, len) { //throw new Error("hello world"); callbacks++; }; -parser.onPath = function (off, length) { +parser.onPath = function (b, off, length) { puts("path [" + off + ", " + length + "]"); - var path = buffer.asciiSlice(off, off+length); + var path = b.asciiSlice(off, off+length); puts("path = '" + path + "'"); assert.equal('/hello', path); callbacks++; @@ -50,7 +50,7 @@ assert.equal(4, callbacks); // thrown from parser.execute() // -parser.onURL = function (off, len) { +parser.onURL = function (b, off, len) { throw new Error("hello world"); };