Live data from Hacker News

Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

unsafehttp.benren.au

41–50 of 54 posts

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#41
post #23

I've got a similar one, but with http 1.0 and partial 1.1 support, multi threaded, etc. in C https://GitHub.com/lionkor/http

Here's one I wrote 25 years ago that was actually used in production for about a decade. For reasons, it ran on a server with 128MB of RAM and served a web/JS chat server for a large number of schools in England.

http://git.annexia.org/?p=rws.git;a=tree

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#42

Nice effort but this isn’t interesting at all. You skipped the most interesting part; parsing http. This is beejs networking tutorial with writing a file to a socket. Harsh? Maybe, but you’re posting this to a site with some of the most talented developers on planet. Real talk, sorry.

Even simple implementations serve as valuable learning exercises, and proper HTTP parsing could be the natural next step in the author's learning journey.

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#43

// it doesn't seem to love piping or redirecting output without this, even // with the newlines above fflush(stdout); Ah, the full buffering mode. I believe it can be fixed by calling setvbuf(stdout, NULL, _IOLBF, BUFSIZ); once at the start. On the whole, it actually almost implements the minimally required amount of HTTP/1.1: I would suggest adding support for HEAD requests, it's just a single flag that you need to…

Ah yep, I read about the TCP RST problem in one of the RFC docs, then promptly forgot about it and never implemented anything to avoid it. Thankyou for the detailed notes.

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#44
post #3

Earlier quoted context omitted.

Whoops, should be back up now. I'll have to check logs later to see why it went down.

You're going to need a bigger host to support HN traffic :)

I wish submitters would try using .onion sites for small static pages, for example as an alternative URL

Fewer source IPs

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#45

Easiest way to make it safe is 1) Run it in a container 2) Isolate it through a reverse proxy, probably nginx

This doesn't make it safe. It can still be exploited and used to join a botnet, as a proxy, to mine cryptocurrency, to spy on requests or redirect users to malicious websites or phish them, to host malware...

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#46
post #28

Nice effort but this isn’t interesting at all. You skipped the most interesting part; parsing http. This is beejs networking tutorial with writing a file to a socket. Harsh? Maybe, but you’re posting this to a site with some of the most talented developers on planet. Real talk, sorry.

Parsing HTTP is entirely unnecessary. That's the web client's job.

Do you mean parsing HTML? HTTP is the protocol they use to communicate, so both client and server must speak it. Or did I misunderstand you?

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#48
I also have a tiny one, used in production with custom decompression and decryption for some IoT devices in the field, which push sensor updates to it. http 1.0 PUT only, multi-threaded and super efficient. One page only (about 50 lines or so). Pretty safe.

Re: Show HN: unsafehttp – tiny web server from scratch in C, running on an orange pi

#50
post #47

> RFC 9112 is a fantastic document that details the exact format of HTTP 1.1 requests, how servers should respond to those requests ... > This server follows almost none of that. This made me chuckle :-)

The comedy continues in the next paragraph:

> Readers MUST NOT hold this against the project, and SHOULD use this as motivation to keep some of their own side projects fun and short.

That's comedy gold, right there. (Tip: RFC-2119)

Post reply on HN