12

I m working with libcurl. It's very good (as client) and I used to open a socket to a server and then send my http packets.

I'm wondering if it's possible to develop http server with the libcurl. the http server will listen on a given port then when it receive a http packet then the http server return a need to a digest authentication.

I made some research in stackoverflow and in the curl website but without result.

Is it possible to do that with libcurl ? and how to do it?

MOHAMED
  • 41,599
  • 58
  • 163
  • 268
  • 1
    cURL is a client-side library, it's not suited for developing a server. –  Feb 13 '13 at 11:01

2 Answers2

16

To repeat what others have said: no, libcurl is not for servers. It is even said in the curl FAQ:

5.17 Can I write a server with libcurl?

No. libcurl offers no functions or building blocks to build any kind of internet protocol server. libcurl is only a client-side library. For server libraries, you need to continue your search elsewhere but there exist many good open source ones out there for most protocols you could possibly want a server for. And there are really good stand-alone ones that have been tested and proven for many years. There's no need for you to reinvent them!

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
3

You need some HTTP server library (since libcurl is only an HTTP client librart) I would suggest to use libonion but there are several other HTTP server frameworks (libmicrohttpd, POCO & Wt in C++, ....).

HTTP is a complex protocol, even if coding a server for a tiny subset (like plain GET requests, without all the useful features like conditional requests, encoding & compression, etc...) of it is reasonably feasible. Hence I recommend using a full-fledged HTTP server library, and that cannot be a tiny library.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547