Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop http server with libcurl

Tags:

c

curl

libcurl

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?

like image 349
MOHAMED Avatar asked Feb 13 '13 10:02

MOHAMED


2 Answers

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!

like image 129
Daniel Stenberg Avatar answered Sep 17 '22 05:09

Daniel Stenberg


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.

like image 28
Basile Starynkevitch Avatar answered Sep 20 '22 05:09

Basile Starynkevitch