https://daniel.haxx.se/blog/2021/05/20/i-could-rewrite-curl/
writing stuff I use is not that much of an effort. However providing various configuration options, handling edge cases and scenarios millions of programmers would like to use... different league.
I love C as much as the next guy, hell, I even write it for fun when I'm feeling down -- but the one thing I won't do, beyond a little "i wrote an http 1.0 server in C" joke project, is networking.
Keep your C offline. If I do networking, it has to be modern C++ with static analyzers, good practices, boost asio, unit testing, and sanitizers, or just Rust, Erlang/Elixir, or whatever other non-C language.
Ive never seen a library get as abused and misused as Curl in source code - well maybe zlib. I think it's great that curl exists, and Im glad its so old that the bugs are mostly worked out, but writing a subset of curl that doesnt have a million issues in a weekend is not so unrealistic.
Edit: Just found this[0], hehe. :)
[0]: https://daniel.haxx.se/blog/2021/05/20/i-could-rewrite-curl/
GET / HTTP/1.0
Host: example.com
over a socket and that's already mostly working. Figure out TLS. Then you just have to do command line parsing and add the stuff you parsed into your request.Is this sarcasm? A joke?
Between the docs[1][2] and the examples[3] I was up and running using my own IO stack in a couple of evenings. If I had used the IO stack from the library it would have been very easy.
Another couple of evenings and I had it integrated with Windows' certificate store. In the end it wasn't very difficult to implement, but it was a bit more of a challenge figuring out the documentation and how it related to mbedTLS.
Definitely a rewarding experience, gave me some nice insights into the plumbing.
edit: Note, not trying to argue replacing libcurl is a weekend project!
[1]: https://mbed-tls.readthedocs.io/projects/api/en/latest/
[2]: https://mbed-tls.readthedocs.io/projects/api/en/latest/api/g...
[3]: https://github.com/Mbed-TLS/mbedtls/blob/development/program...
Othwerise for basic HTTP version, I'll use Fetch API that has TLS already figured out. https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
Even with just http(s), what you describe is just a tiny fraction of typical use cases, even if you ignore all the rarely used bits.