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.
Althttpd: Simple webserver in a single C file
81–90 of 345 posts
Re: Althttpd: Simple webserver in a single C file
#82Earlier 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.
There are also keep-alive, caching (a big topic), chunked transfer encoding, header parsing peculiarities, and authentication in HTTP. The combination of these creates some nice opportunities for implementation bugs. Source: have worked on a client-side implementation. Now, HTTP/2 isn't even conceptually simple, I agree about that... it seems ugly.
Re: Althttpd: Simple webserver in a single C file
#83Earlier quoted context omitted.
And capitalisation issues, and encodings… give me a binary protocol to parse any time. They’re normally comparatively well-defined, whereas text protocols are seldom properly defined and so have undefined behaviour left, right and centre, which inevitably leads to security bugs—or even if they are well-defined, they’re probably done in a way that makes your language’s string type unsuitable, and makes parsing more co…
Just use recordflux for binary parser proved absent of runtime errors... ;-)
Re: Althttpd: Simple webserver in a single C file
#84Earlier 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.
On a more personal note, wow! I had no idea I started using the Internet for realz before the release of Apache, in 1994. This young made me feel, not.
Re: Althttpd: Simple webserver in a single C file
#85Here 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…
Re: Althttpd: Simple webserver in a single C file
#86Re: Althttpd: Simple webserver in a single C file
#87One file of 2600 lines, guess if you give up common sense and follow this approach you can even create a kernel in one file
One file is easy to add into a project, and the compiler optimizes translation units better, so you get a bit of a performance increase in some cases.
Having "Find symbol in file" is nice too if you know you are looking for it just in this one file related to the code. Most editors aren't as ergonomic for finding "symbol in current directory" as they are for "symbol in current file".
Re: Althttpd: Simple webserver in a single C file
#88> A separate process is started for each incoming connection, and that process is wholly focused on serving that one connection. It makes you wonder just how "heavy" operating system processes actually are. We may not need to worry about the complexity of trying to multiple run async requests in a single process/thread in all cases.
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
Re: Althttpd: Simple webserver in a single C file
#89Re: Althttpd: Simple webserver in a single C file
#90> A separate process is started for each incoming connection, and that process is wholly focused on serving that one connection. It makes you wonder just how "heavy" operating system processes actually are. We may not need to worry about the complexity of trying to multiple run async requests in a single process/thread in all cases.