would folks be interested in an "implement a toy version of HTTP/1.1 in a weekend” guide? I'm imagining something super basic (~100 lines of Python, not remotely standards compliant), just a server that opens a TCP socket, takes HTTP requests, and returns responses.
also makes me wonder how complicated it would be to write a toy version of http/2
@b0rk Now do FTP. ;-)
(kidding, that was one of the brutal class assignments some of my friends had to do in college)
@b0rk that requires more intermediary steps as it's no longer a plain text protocol. :(
@b0rk probably far more complicated because of the channel muxing and the need for TLS. But would be cool to see what minimal code is needed for a basic connection to work.
@cramer @b0rk I don't think you actually need TLS. Is just that most browsers insist you use it. If you don't, I reckon HPACK encoding would be the most difficult part of this.
@seanddotmedotuk @b0rk True, TLS is technically not needed. But no real browser supports it without.
@cramer @b0rk With the exception of curl. πŸ˜ƒ
@b0rk HTTP/2 server push is surely fun to implement - Google removed support in Chrome because "too complex" πŸ˜…
@b0rk well in practice TLS is mandatory so
@alilly i mean I think it's reasonable to use a library to handle the TLS and just implement the HTTP/2 part

@b0rk @alilly That would have to be it's own weekend? ;-)

I don't know whether that's actually feasable, & you would need to warn people not use your code... But it'd a fascinating read!

@b0rk even more interested in this, especially since I don't understand how it can be binary while so much of http almost obviously requires plain text.
@b0rk @danfuzz didn’t you just implement something simple from scratch?

@mikemccabe @b0rk My thinger is at a higher layer than what @b0rk is suggesting. Specifically, I use the HTTP* stuff provided by Node.

(That said, many years ago I _did_ build a simple HTTP server from scratch, in Java. Like around 1999 or 2000 maybe? I wouldn't recommend using it at this point!)

archive/tinyweb at main Β· danfuzz/archive

Archive of inactive projects. Contribute to danfuzz/archive development by creating an account on GitHub.

GitHub
@b0rk I'd love to see that. There's a few toy http1 out there already, (including awk https://github.com/kevin-albert/awkserver/blob/master/src/http.awk) but I've never seen http2.
awkserver/http.awk at master Β· kevin-albert/awkserver

A minimal HTTP server that runs in GAWK. Contribute to kevin-albert/awkserver development by creating an account on GitHub.

GitHub
@b0rk
Oh yes! The DNS one was very interesting, I'd love to see more like that!
@b0rk yes please! I loved the dns one! πŸ˜€
@b0rk this seems like a fantastic use case for reviving the 'upsidedownternet' project from a jillion years ago :D
@b0rk I've written a few of those! Here's one, and the page has links to more by me and others. http://acme.com/software/micro_httpd/
micro_httpd

@b0rk yes because this might even be actually useful as a sanity/debug tool...

@b0rk bonus points for the client being telnet.

A university project was to implement rfc2324 which was quite a good demo of making an "http" server. We were awarded bonus points if our client could talk to other servers. Or vice versa.

https://www.ietf.org/rfc/rfc2324.txt

@b0rk These things are super to understand that you could do it yourself :)
And how things actually work behind the scenes.

On http I am personally annoyed by the referer header spelling, that wasted some hours in the day.

Thanks for your work and hints to interesting things.

@b0rk I think I’d find that way more useful than DNS
@b0rk
That would be cool indeed!

@b0rk I loved this post when I saw it which is kind of the same thing so, yeah, I think is an awesome idea

https://blog.bjartnes.dev/posts/http-love/

blog.bjartwolf.dev

@b0rk HTTP, like SMTP, can be accessed and operated via telnet. That might be interesting, but as a person who got started writing web apps using the Common Gateway Interface, it might be more interesting to show people what a framework free web app looks like. Both would help new people understand a couple layers closer to the metal than they might currently operate.
@b0rk That sounds like something I would enjoy.

@b0rk is this a good time to mention that https://txt.friday.horse is written in awk, only proxied to get ssl but actual HTTP in gnu awk.

The simplicity of HTTP 1 for like 80% of the features is so fun and convenient... I think exposing more people to that is a great idea

@b0rk @codefolio has a WIP book that goes down this road, but in Ruby, though, as I understand it, it goes a little further beyond a weekend.

The more the merrier!

@sakiamu @b0rk Yup, I have a book on that (https://rebuilding-http.com). But as you say, the more the merrier!

And yeah, you could totally get to a basic one in a weekend.

And yeah, Ruby not Python, so only sort of the same audience πŸ™‚

Rebuilding HTTP - Understand HTTP by Building an HTTP Application Server

Rebuilding HTTP, an ebook about understanding HTTP by building your own HTTP implementation from the sockets up

@b0rk I remember implementing http and smtp for a mudlib in LPC. I bet the impl is embarrassing, but it did its job. If you look at it from a certain angle, squinting.
@b0rk this would be a super useful resource for junior engineers on my team, I think

@b0rk yes, I'd be super interested.

Your "you can just send a hand written GET using netcat" example was super helpful in making HTTP much more accessible and easy to reason about for me

@b0rk so no chunked encoding, ranges, gzip, keep alive, multipart mime, or other bells? Maybe target 1.0? What about POST?
@msokolov Definitely POST. I was thinking of adding a bunch of extras as exercises so that people can implement whatever bits they're interested in

@msokolov @b0rk Gzip is a higher-level concern (transfer encoding is pretty high-level), as is MIME anything. Keep-alive is easy enough even with HTTP 1.0 v. 1.1 differences. (1.1 just makes it the default.) Chunked encoding is the low level side of this, especially as everyone forgets HTTP header "trailers". (Sending headers at the end of a chunked transfer, not the start. Useful for generating Content-MD5 and such on the fly.) POST is just a verb.

I've linked my hybrid HTTP service before. 😜

@b0rk so much of this reminds of this article: https://medium.com/@zarkzork/recreational-programming-279e330c6f9a and why I started writing code to begin with #makecodefun
Recreational Programming – Vladimir Terekhov – Medium

Rediscover the Joy of Coding

@b0rk Heh, I wrote the worst β€œserver” imaginable in portable shell printf & netcat as an integration test subject for HTTP nagios plug-ins years ago.

I expect to be amazed with what ~100 lines of clear python can deliver.

@josephholsten It’s kind of amazing how simple a lot of these technologies fundamentally are when you dig in. Writing an HTTP server in C back in college was a revelation at how little there actually is at the core.
@alpha A webmachine level of protocol correctness, with efficient file system access, caching and C10k concurrency: a deeply challenging project.
A derpy 200 OK loop on a socket: a delightful example of why 4.3BSD TCP/IP socket API won

@b0rk This is the magic weekend stuff where you wake up the next day and find out that 20 years of maintenance have gone by.

But Iβ€˜d prefer to encounter your toy versions in production to other copy&pastes.😌

@b0rk Maybe in the future, an explainer about the different HTTP versions including QUIC/HTTP3 since it's becoming common.