Open MartinNowak opened 9 years ago
This is the new HTTP parser: https://github.com/etcimon/libhttp2/blob/315178a19dbaee98dab6ac9a950ec361f56fb84f/source/libhttp2/huffman.d#L345
^^
Looks like a DFA? Interesting.
Tip: To get a permalink to a line in a file, press y
.
https://help.github.com/articles/getting-permanent-links-to-files/
Tip: To get a permalink to a line in a file, press y.
And I'll remember that =)
Looks like a DFA? Interesting.
They're generated through a python script from nghttp2: https://github.com/tatsuhiro-t/nghttp2/blob/948d4d43d5f10240d991f70489fea89b62958381/mkstatichdtbl.py
That table is standard protocol so I didn't need to include the python.
edit: everything is standard protocol now ^^
Tip: To get a permalink to a line in a file, press y.
And I'll remember that =)
Ditto! That's really helpful.
BTW, I still have some beginnings of a HTTP/2 implementation lying around that I started back in October. It's far from being a complete implementation, but integrates nicely with the API. Do you have started anything w.r.t. vibe.d integration, yet? I'd have to take a closer look and think about an optimal design if we are going to use the nghttp2/libhttp2 code.
Do you have started anything w.r.t. vibe.d integration, yet?
This is the current file: https://github.com/etcimon/vibe.d/blob/7303c350048ea544932b167ffecea5aacd72a124/source/vibe/http/http2.d
Basically, an HTTP2Session is created and its internal event loop started when the TLS ALPN extension has the supported protocol or when the Upgrade: h2c
header field is detected. The underlying stream (bodyWriter, etc.) is implemented as HTTP2Stream
and instantiated by calling HTTP2Session.startRequest()
and a new HTTPServerRequest or HTTPClientRequest is created like usual.
Basically, the HTTP2Stream
is a ConnectionStream
that supports readHeader
and writeHeader
, where header is a struct HTTPHeader
and contains InetHeaderMap
and URL
. The HTTP2Session
is like the Kernel event loop, with a task that loops for read and another task that loops for write. The HTTP2Stream
is like the TCPConnection
but without the TCP features, with an integrated blocking header parser/receiver, and some options to adjust the circular buffer size (Window Size).
I plan on having setHeader
and writeBody
in the stream directly as well so that internally you can atomically send the request using the libhttp2.session.submitRequest
or response using libhttp2.session.submitResponse
along with the END_STREAM flag.
The close() function just pipes through to a RstStream frame otherwise. Same for errors.
I think I can have this done within a few days, but obviously I could be wrong again about the timeline :) What do you have on your end btw
+1: It would be awesome to get a parsing benchmark out there comparing the latest Vibe parser against Node.
There is also https://github.com/bithavoc/http-parser.d from @bithavoc How about adding it to the benchmark and comparing all four?
The node.js HTTP parser is a small self-contained project. https://github.com/joyent/http-parser It would be interesting to compare vibe.d's current parser against this, both for performance and correctness.