Skip to content
Permalink
Browse files
API Change! Instead of two events "on_header_field" and
"on_header_value", emit these as a single "on_header" event that is
passed in two arguments.  This API should be slightly easier to use.

I also removed the redundant cb_id field from lhttp_parser so the
overhead of a parser was reduced by 4 bytes.  However, to facilitate
calling a 3 argument function, the procol between the lua
implementation of "execute" and the C implementation had to change.
The new protocol is to push a count of how many items are on the Lua
stack followed by the function followed by the arguments to that
function.

After this change the benchmarks are about the same even though a
function call was eliminated.
  • Loading branch information
Brian Maher committed Jan 3, 2011
1 parent 9728092 commit 64624c3
Show file tree
Hide file tree
Showing 3 changed files with 269 additions and 169 deletions.
@@ -111,7 +111,6 @@ local function init_parser()
local reqs = {}
local cur = nil
local cb = {}
local header_field = nil

function cb.on_message_begin()
assert(cur == nil)
@@ -136,16 +135,9 @@ local function init_parser()
end
end

function cb.on_header_field(value)
assert(nil == header_field)
header_field = value
end

function cb.on_header_value(value)
assert(header_field ~= nil)
assert(cur.headers[header_field] == nil)
cur.headers[header_field] = value
header_field = nil
function cb.on_header(field, value)
assert(cur.headers[field] == nil)
cur.headers[field] = value
end

function cb.on_message_complete()
@@ -164,8 +156,7 @@ local null_cbs = {
"message_begin",
on_path = null_cb, on_query_string = null_cb, on_fragment = null_cb,
on_url = null_cb,
on_header_field = null_cb,
on_header_value = null_cb,
on_header = null_cb,
on_headers_complete = null_cb,
on_body = null_cb,
on_message_complete = null_cb,

0 comments on commit 64624c3

Please sign in to comment.