I am looking for the smallest possible **working** C++ code for an http server. My requirements:
1. Source code must have no external dependencies dependencies that do not come pre-installed on ubuntu
2. Must work on Ubuntu.
3. As small and simple as possible. I will be modifying it heavily. No need for security, encryption, no fancy stuff.
What would you recommend? Also, I know next to nothing of how http servers work, would you recommend a quick tutorial (hopefully less-than-an-hour-one)?
***
At the moment I am using an apache webserver, calling my application using CGI. However, I need a more detailed communication with the web browser: I am doing a large computation, and need to display various counters and progress reports. The computation may take upwards of a day, with multiple phases and a number of progress reports. I need to make those run smoothly (without any of the built-in timeouts and safeguards of the apache server).
Last but not least, maintaining the apache configuration has been a royal pain in the butt: every Ubuntu update and every new machine breaks my configuration. Getting my own http server will save me from all that trouble.
An alternative to using a tiny webserver so you can customize it, is to go the other way--use conventional (defacto) standards.
In your case, you want something that runs in the background doing the calculations, but an HTTP interface that provides access to counters.
You can do this using custom pages that query the running "thing" and displays the results, or you could provide a REST interface to allow programmatic access to the counters.
I have to agree with Cubbi. What you're asking sounds like the job for a script to me.
However, if you are going to use C++, I would look into libmicrohttpd [ https://www.gnu.org/software/libmicrohttpd/ ]. I'm not sure if it's pre-installed in Ubuntu now, but I know there are a lot of commonly-installed applications that use it as a dependency. It's a lot faster and lighter than non-C implementations I've used before. I'd give it a good look.
I don't know what your end goal consists of really, but any incarnation of libwebkitgtk may also be more what you're looking for - instead of an actual server (i.e. you are reading the reports on the machine rather than serving them to read elsewhere). It is installed by default on some flavors of Ubuntu and Debian, but it's not preinstalled on every implementation (I don't even know about the default Unity-using Ubuntu). It lets you create a fully-featured browser with a couple lines of code, and it is still relatively fast. I've used this before to make reports, and it's very flexible. I know that Linux Mint (an Ubuntu derivative) uses libwebkitgtk inside it's login screen manager, MDM. It lets your reports be made in an HTML format and styled using CSS. Events can be handled in either C or JavaScript (or even other languages if needed).
I don't _think_ libwebkitgtk is what your looking for, but I'd definitely give libmicrohttpd a good look.
Civetweb (based on Mongoose) is a C (with C++ bindings), cross-platform, embeddable or standalone webserver implementation. It supports HTTPS, WebSockets, CGI, WebDAV, etc. It can also function as an HTTP client. The interface is pretty comprehensive and easy to use (adding request handlers, rewriting URLs, etc). Comes complete with a Makefile for building standalone, static library, shared library, docs, etc. It's MIT licensed, so you can use it in commercial projects.