One file of 2600 lines, guess if you give up common sense and follow this approach you can even create a kernel in one file
Althttpd: Simple webserver in a single C file
31–40 of 345 posts
Re: Althttpd: Simple webserver in a single C file
#32I'd be putting this in 1000 layers of sandboxing since its a C program with network access.
Re: Althttpd: Simple webserver in a single C file
#33/* ** Test procedure for ParseRfc822Date */ void TestParseRfc822Date(void){ time_t t1, t2; for(t1=0; t1 There's only two billion integers, guess we can test them all. Well, substantially fewer than two billion with that skip. I wonder if that completes in a few seconds.
Re: Althttpd: Simple webserver in a single C file
#34One file of 2600 lines, guess if you give up common sense and follow this approach you can even create a kernel in one file
AFAIK FreeRTOS is a kernel and distributed as a single file.
Re: Althttpd: Simple webserver in a single C file
#35It 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.
Re: Althttpd: Simple webserver in a single C file
#36Here 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…
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.
Now, HTTP/2 isn't even conceptually simple, I agree about that... it seems ugly.
Re: Althttpd: Simple webserver in a single C file
#37Here 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…
HTTP is serious about backward compatibility, so a client that speaks HTTP/1.1 (or HTTP/1.0 + Host header) can still talk to most servers out there. Similarly, if you write a server that only speaks HTTP/1.1 (or HTTP/1.0 + Host header), you can put it behind a reverse proxy or load balancer that handles higher versions, does connection management, and terminates TLS. It will work perfectly fine, only without some of…
This is even standard practice in many production deployments. Typically you want the proxy or load balancer anyway and there's often little benefit (if any) to using HTTP/2 or HTTP/3 over a very low-latency, high reliability local network.
Re: Althttpd: Simple webserver in a single C file
#38Earlier quoted context omitted.
HTTP is serious about backward compatibility, so a client that speaks HTTP/1.1 (or HTTP/1.0 + Host header) can still talk to most servers out there. Similarly, if you write a server that only speaks HTTP/1.1 (or HTTP/1.0 + Host header), you can put it behind a reverse proxy or load balancer that handles higher versions, does connection management, and terminates TLS. It will work perfectly fine, only without some of…
That seems like a high risk of http desync attacks, if you're only implementing a subset of http/1.1.
Re: Althttpd: Simple webserver in a single C file
#39One file of 2600 lines, guess if you give up common sense and follow this approach you can even create a kernel in one file
Re: Althttpd: Simple webserver in a single C file
#40Here 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…