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?
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With