Fedor Indutny
Used a lot by frontend tooling
Great backend platform!
started with http_parser...
Is libuv the oldest dependency?
No!
http_parser is!
To celebrate this
I wrote another HTTP parser
One character at time
(e.g. header names/values, body)
for
" loop over inputswitch
" for states
All in a single function!
switch
" into pieces
goto
" between states
(Can be used for other protocols!)
const node = program.node('name');
node.match('keep-alive', next);
node.peek(' ', next);
node.select({
'0': 0, '1': 1, '2': 2,
'3': 3, '4': 4, '5': 5,
'6': 6, '7': 7, '8': 8,
'9': 9,
}, next);
(invoke callback)
const store = program.code.store('method');
node.select({
'GET': 0,
'PUT': 1,
}, program.invoke(store, next));
const cb = program.code.span('header');
const header = program.span(cb);
header.start(
node.match(' ', header.end(next)));
node
.match('a', childA)
.match('b', childB)
.otherwise(somethingElse);
node
.match('a', childA)
.skipTo(somethingElse);
llhttp is a TS program
Different sub-parsers in
different files
llparse transpiles TS program
to C
No syntax checking
JS engine handles it!
C has better performance 😳
Not hand-written!
Not hand-optimized!
is 2x faster!
llhttp | http_parser |
3'020'459 RPS | 1'406'180 RPS |
...and tag me on GitHub
Easy to read, easy to contribute
In-test textual description
vector instructions
(e.g., SMTP, POP3)
Link incoming...