3 ms·
You're thinking of https://github.com/for-GET/http-decision-diagram https://github.com/for-GET/http-decision-diagram
by niftich 10y ago
You're thinking of https://github.com/for-GET/http-decision-diagram https://github.com/for-GET/http-decision-diagram
- jahewson 10y agoThat's the state diagram for processing the full complement of HTTP requests. Nothing to do with parsing. The parsing bit is trivial.
- niftich 10y agoWhile you're correct that it's a state diagram processing HTTP semantics and not parsing; parsing a text-based protocol is far from trivial. In fact, the HTTP2 FAQ explicitly mentions [1] that reducing parsing complexity was a motivation for going binary with HTTP2. [1] https://http2.github.io/faq/#why-is-http2-binary https://http2.github.io/faq/#why-is-http2-binary
- nostrademons 10y agoI've done perfectly adequate HTTP parsing with this Python 4-liner: headerText, body = text.split('\r\n\r\n', 1) headerLines = headerText.split('\r\n') method, path, protocol = headerLines[1].split(' ') headers = dict(line.split(':').map(str.strip) for line in lines[1:]) For production use you'd probably want something a bit faster & more robust like Mongrel's HTTP parser (itself only 166 lines of Ragel), which powers several million websites out there: https://github.com/mongrel/mongrel/blob/master/ext/http11/http11_parser.rl https://github.com/mongrel/mongrel/blob/master/ext/http11/ht...
- niftich 10y agoThat's a perfectly adequate 4-line HTTP/1.0 parser :) But for HTTP/1.1, which must support chunked transfer coding [1], this won't work. [1] https://tools.ietf.org/html/rfc7230#section-4.1 https://tools.ietf.org/html/rfc7230#section-4.1
- captn3m0 10y agoI'm going to convert this into a poster and get this printed