Mordinel / hussar

A multi-threaded web server framework
GNU General Public License v3.0
0 stars 0 forks source link

Implement an HTTP client #8

Open Mordinel opened 2 years ago

Mordinel commented 2 years ago

Could be a wrapper around CURL apis, or something custom with thread.h.

Mordinel commented 2 years ago

some static api like hussar::HTTP(GET, "hostname", "query", "body"); would be ideal and/or have something like hussar::HTTP::Request(config); where config is a struct like:

struct {
    hussar::HTTP::method;
    std::string host;
    uint16_t port;
    std::string query;
    std::map<std::string, std::string> headers;
    std::string body;
};
ignacionr commented 2 years ago

Let me share with you my experience with https://github.com/cesanta/mongoose ; it's a top-notch web server, it is incredibly well written, it basically uses the concept of std::string_view everywhere it needs to parse (even though it is C not C++ all around) and very popular. They support a client api that they never get time to look after, and works... on some cases. It particularly has a bunch of issues with its usage of DNS.

Crazy as it may seem, the further I look into it, the more different Web Server and Web Client look (like different realms).

LibCurl works incredibly well, so much so that you will even find it installed in most places/platforms/architectures.

My advice, don't get into client. Caching and DNS usage just to name two items, are completely off the server realm.