GNU libmicrohttpd 1.0 Released - The Web For IoT
Written by Harry Fairhead   
Monday, 05 February 2024

The IoT is very dependent on web technologies, but for many applications the software needed is excessive. libmicrohttp is a small C library that lets you add HTTP to your C programs.




The big problem with the web is that it has evolved to the point where its protocols are difficult to implement if you have to do it from scratch. It is only relatively recently that we have been able to select devices that are powerful enough to run a desktop operating system for IoT or embedded tasks. Having an operating system can make things more difficult for basic tasks that involve accurate timing, but having high-level features like files and graphics make things easier.

There are areas where its more difficult to decide how to proceed. For example, what should an IoT program that wants to expose a web interface do? One possiblity is to use a full web server like Apache, but in many cases this is not only overkill but a security risk. If all your IoT program wants to do is send a few static pages with some dynamically generated content then having a full web server is a nightmare to configure properly.

HTTP is simple enough to implement on your own server or client, but it quickly becomes difficult to keep up with the possible headers that could be in use and it gets difficult when you throw in HTPPS or anything to do with encryption. For small devices that don't run a desktop operating system there are some libraries that provide basic HTTP and even encryption, but for desktop machine, there is a general assumption that you might as well install a full server. If you don't want to do this then there are few obvious C libraries that will do the job. One such was libmicrohttpd, a GNU project, but it was looking a little neglected until recently Now we have a version 1.0 release and a promise of more activity.

The stated good points of the release are:

  • C library: fast and small
  • API is simple, expressive and fully reentrant
  • Implementation is HTTP 1.1 compliant
  • HTTP server can listen on multiple ports
  • Various threading modes: run in application thread, internal thread, thread pool, and thread-per-connection
  • Three different sockets polling modes: select(), poll(), and epoll
  • Minimised number of sys-calls to avoid extra user/kernel mode switches
  • Supported platforms include GNU/Linux, FreeBSD, OpenBSD, NetBSD, Android, Darwin (macOS), W32, OpenIndiana/Solaris, and z/OS
  • Support for IPv6
  • Support for SHOUTcast
  • Support for incremental processing of POST data (optional)
  • Support for basic and digest authentication (optional)
  • Support for TLS (requires libgnutls, optional)
  • Binary is only about 32k (without TLS support and other optional features)

At 32k it is certainly small enough to use on an IoT device. It is easy to use and you can use it to serve multiple requests in different threading modes. If you want to use encryption then you need an additional package. At the moment only libgnutls is supported, but this does seem to be under active development.

The even better news is that the there are plans to develop it further:

Work will now begin work on a 2nd major version of GNU libmicrohttpd.This version will have an easier to use API, add support for HTTP2 and HTTP3, as well as multiple TLS backends.

My only observation is that in today's climate separating HTTP and TLS libraries isn't really a good way to work. HTTPS is now so standard that we need any HTTP library to support HTTPS out of the box - not as an optional extra but as an optional disable.


More Information

GNU Libmicrohttpd

Related Articles

Master The Pico WiFi: Simplest HTTPS Client

Google Chrome Will Enforce HTTPS By Default

ESP32 In MicroPython: Client Sockets

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.



Rust Wins Award For Significant Impact

The Rust Language was the winner of the 2024 ACM SIGPLAN Programming Languages Software Award which recognizes a software system that has had a significant impact and carries a prize of $2500. Th [ ... ]

Apache Releases NetBeans 22

Apache NetBeans 22 has been released. This release has a new Gradle Wizard, upgrades to Java 22 javac, and a number of UI changes.

More News

kotlin book



or email your comment to:


Last Updated ( Monday, 05 February 2024 )