Philip
Philip

Reputation: 3500

Simple HTTP Server lib

What is a good choice for a simple http Server lib? It doesn't need high performance. I rather look for something simple for some REST/JSON communication ("API").

It must be able though to work in a multithreaded environment and must be able to handle large POST request.

Any suggestions? I already tried cpp-netlib but this seems to be much too complicated for such an easy task...

Edit: I am looking for something really light-weight and simple. E.g. like Sinatra in the Ruby world. Poco is for me another example of a too heavy-weight library.

Upvotes: 7

Views: 14228

Answers (5)

rlc
rlc

Reputation: 2857

Personally, I'd go for Arachnida but that might be because I wrote it.

Upvotes: 1

Vu Tung Lam
Vu Tung Lam

Reputation: 153

Pretty late answer; but hope this helps.
For your interest of a server that can handle REST, here is the easiest HTTP Server library to use (in my opinion): https://github.com/yhirose/cpp-httplib.
For JSON parsing, you may search for another library to use it in conjunction.

Upvotes: 2

madeso
madeso

Reputation: 317

Not sure about large POST data, but I've previously used mongoose: https://github.com/cesanta/mongoose/.

If the LGPL license is unwanted there is a MIT fork from when the project was MIT that also add a C++ API https://github.com/bel2125/civetweb

Upvotes: 5

bronekk
bronekk

Reputation: 2129

I would encourage you to start with http server samples in boost.asio. They are so simple and easy to understand, that you should be able to easily extend them as needed.

However, if you want to jump onto something more polished than just sample code, I know of 3 http servers in C++ which you may like to try:

  • "x0 - HTTP Web Server Framework" to me personally this one seems most promising, because it's lightweight and simple
  • "highpower / xiva" is a simple http server framework for delivering notifications to browsers
  • "Pion, a project of Atomic Labs" is a part of elaborate framework for handling large amounts of data

Upvotes: 4

hsmith
hsmith

Reputation: 184

The first one that comes to mind is Poco Library ( http://pocoproject.org/ )

Cross platform, stable, well documented. While the library itself offers more than you probably need you can build and omit the portions you aren't planning on using to reduce bloat.

They have a fully featured Net library that includes several salient classes and utilities.

Here is a pdf of slides from that library, of particular interest is the HTTPServer class: http://pocoproject.org/slides/200-Network.pdf

Upvotes: 12

Related Questions