Hackaday Prize Entry: Minimalist HTTP

For his Hackaday Prize entry, [Yann] is building something that isn’t hardware, but it’s still fascinating. He’s come up with a minimalist HTTP compliant server written in C. It’s small, it’s portable, and in some cases, it will be a bunch better solution than throwing a full Linux stack into a single sensor.

This micro HTTP server has two core modules, each with a specific purpose. The file server does exactly what it says on the tin, but the HTTaP is a bit more interesting. HTTaP is a protocol first published in 2014 that is designed to be a simpler alternative to WebSockets.

[Yann] has been experimenting with HTTaP, and the benefits are obvious. You don’t need Apache to make use of it, HTTaP can work directly with an HTML/JavaScript page, and using only GET and POST messages, you can control hardware and logic circuits.

As this is a minimalist HTTP server, the security is dubious at best. That’s not the point, though. This is just a tool designed for use in a lab or controlled environments with an air gap. Safety, scheduling, encryption, and authentication are not part of HTTaP or this micro HTTP server.

27 thoughts on “Hackaday Prize Entry: Minimalist HTTP

  1. Thank you Brian, it’s a pretty good summary, I was too waist-deep in the code to come up with it :-)

    The HTTaP module is going to be upgraded to a better, more modular system so people don’t have to modify the core server’s source code, but you know the tune, work and other projects are always getting in the way…

      1. Hi,
        Yes i’ve looked at them already :-)
        My use cases however require dynamic switching from polling to blocking behaviour because of the way it interacts with a possible user-made wrapper. Multithreading is not possible and race conditions must be avoided… but the application must still be responsive, whether it uses 100% or 0% of the CPU…
        Oh I forgot : I need to have everything under AGPLv3 for coherence and convenience.
        In the end I had a set of requirement so specific that hacking another lib woud have been too hard.

        After this is solved, the other part of the equation is to get/make a TCP/IP stack. So far I use the hardware stacks from Wiznet so it saves a lot of hassles :-)

    1. OK,it’s so much shorter than the HTTaP server because I had to write the interface with the POSIX sockets in C at the low level, fine-tune certain details, extend to the most general cases… The actual “HTTP” part is pretty small and it’s an ignored fact that despite the moutains of RFC, the principles of HTTP are ridiculously simple (which explains its success)

      1. Of course. This is not some sort of contest, I just wanted a quick and reasonably non-dirty way of exposing a microcontroller. I can write C just as well as Python but why bother if it’s a hindrance? (the Xtensa toolchain alone is aggravating enough)

        1. The point of developing this microserver is to make this sort of hack very easy and yet very low footprint while still being powerful, and without any OS. For now it is being developed for the RPi under Linux but hopefully it can be ported to µC (such as the YASEP ;-) )

    1. Wow !!! That’s impressive ! I’m not sure it would help HTTaP (you use pthreads while I use single-threaded code and switch from polling to stalling and back, as desired) but it certainly helps some of my other needs :-D
      How come I haven’t heard about this code before ?
      Thanks for your tip !

  2. I hope this takes off for those who do micro-controller projects.

    Most HTTP stacks I see are bloatware and need at least 32 bits and lots of RAM to get off the ground.

    As [Yann Guidon / YGDES] said above Quote: “despite the moutains [sic] of RFC, the principles of HTTP are ridiculously simple”

    The vast majority of internet protocols like email servers are also incredibly simple and can easily run on an 8-bit. They’re all just ‘Stringy’ protocols that need a fair amount of ROM (FLASH) for the strings and very little RAM and CPU power and that quite well describes the 8-bit end micro-controller hierarchy.

    There are also lots of protocol gateways out there if you don’t want to write your own. Want to send a SMS, no problem find a SMS gateway that has an API that accepts requests via HTTP.

    This is an excellent project and it’s the missing link for a lot of hackers/engineers that have been shy of internet protocols. Now they have something written in a language they are familiar with and can be used directly or serve as a learning experience to understand just how simple internet or TCP/IP protocols are so they can go write their own.

    +10 to Yann Guidon / YGDES

    1. Thank you Röb ! I feel vindicated by your post :-)
      I didn’t create HTTaP in the void : I’ve seen the first PIC-based servers using ISA cards and I’ve worked with the Rabbit Semiconductor micro web server, which is entirely written in C and which I had modified for my own purposes 12 years ago… But this code is proprietary so I HAD to make an open source, tailored version.
      Developing the YASEP framework made me understand that the browser was like an autistic genius and needed an easy, simple communication system so I created the HTTaP sub-protocol (despite the existence websockets).
      I also need to host the JS application on the same server (to avoid cross-origins limitations) so this slowly shaped the dual-use server that is described in this post…
      One goal is to make the server run on the YASEP (one day :-) )
      So yes, the “missing link” argument was my motivation all along :-D

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s