Live data from Hacker News

Althttpd: Simple webserver in a single C file

sqlite.org

91–100 of 345 posts

Re: Althttpd: Simple webserver in a single C file

#92
post #50
post #2

Here is the actual single C-code file: https://sqlite.org/althttpd/file?name=althttpd.c Something I absolutely love about text based protocols such as HTTP/1 is how easy you can implement it in any virtually programming language. Sure, the implementation is not top-of-the-notch, but it just damned works, it is portable, it is understandable by humans. That's something what's got lost with HTTP/2 and HTTP/3, respectiv…

Binary protocols aren't (or at least don't have to be) any more difficult and frequently are even easier to implement. Text protocols have difficult problems like escaping or detecting the end of particular field that are frequent source of mistakes. The issue is that many (especially scripting) languages treat binary data as second class. The only real issue is that inspecting the binary message visually is little b…

I did implement a webserver (that supports websocket-a binary protocol) and also implemented a `make_binary_string` function along the wah so as to not lose my bearings. Printf is 100% amazing and I generally leave my printf statements inside all my code because I can switch them on and off very easily for any individual function by using macros. Also clutch :)

Re: Althttpd: Simple webserver in a single C file

#93
post #13

Earlier quoted context omitted.

> [Althttpd ...] has run the https://sqlite.org/ website since 2004 I don't know what the landscape was like in 2004 really, but probably at least an order of magnitude less than today's bazillion (whatever that would be!).

I don't think Nginx was out then, so I was using Apache HTTPD. Maybe Dwayne considered that too heavy for what he needed to serve up.

Nginx’s first public release was Oct 2004, so fits with your theory.

Re: Althttpd: Simple webserver in a single C file

#94

Earlier quoted context omitted.

HTTP/1 simplicity comes not from text nature, but from it's clear concept and limited functionality. At core, it's just request-reply + key-value metadata. Whenever it's text, or binary, it does not matter much. But writing HTTP/2 frame types in letters would not make them any easier to understand.

HTTP allows a TimedOut response to be sent by a server to request you haven't yet sent. So it's not strictly request/reply.

'100 Continue' would probably be better example of breaking request/reply flow, as it provides useful functionality and requires non-trivial implementation and compatibility measures.

While '408 Request Timeout' is somewhat dubious fig leaf over TCP RST

Re: Althttpd: Simple webserver in a single C file

#95

Earlier quoted context omitted.

Apache's thread-per-connection model used to run basically the entire internet until nginx came along and demonstrated 10k simultaneous connections on a single server. If you only have around 100 concurrent confections, a separate thread per connection is entirely feasible. A whole new process is probably fine on Linux, but e.g. Windows takes pretty long to spawn a process

If you have 100 concurrent confections you're probably baking cookies.

But you can probably get away with using one regular commercial oven instead of getting a baking tunnel oven :)

Re: Althttpd: Simple webserver in a single C file

#97
post #16

I'd be putting this in 1000 layers of sandboxing since its a C program with network access.

if you run gnu/linux and are worried by C code running... I have bad news for you.

The google security team is working on fixing this with rust.

Re: Althttpd: Simple webserver in a single C file

#98
post #81
post #16

Earlier quoted context omitted.

if you run gnu/linux and are worried by C code running... I have bad news for you.

His operating system is probably GNU/Docker.

Not far off it. I run fedora silverblue with is flatpak and podman

Re: Althttpd: Simple webserver in a single C file

#100
post #91

Take a look at Fossil too: https://www.fossil-scm.org/ It's the distributed version control (and more) used by SQLite. Most people have no idea about how cool the SQLite ecosystem is, and how it's used even on avionics!

The lack of ability to squash PRs into single commits is a deal breaker for many, myself included.

No, having a commit "fix typo" in the main branch's history is not at all useful and won't ever be. It's noise.

In a work setting it's much better to reduce noise.

Post reply on HN