It’s beautiful, but it isn’t wget.
It might be better to call it curl in 50 lines of C: It would still be a lie, but it would be less of a lie, and more descriptive, given that both programs sit on top of HTTP libraries which are intended to be reusable.
As a piece of more constructive commentary, it would be useful for the library to export a function which parses URIs into their various components. The fact this toy program has to accept them in pre-chewed form indicates it’s precisely the kind of thing you want to hand off to external code.
delete the comments and libcurl lets you do it in 15 lines: https://raw.githubusercontent.com/curl/curl/master/docs/examples/https.c
This looks great. Is this library being written to be part of some large application?
I’ve written ZeroMQ and nanomsg once. This is part of my years-long project to make writing such applications tractable. And by that I mean being able to write them without falling into either callback hell or state machine hell.
On that topic, what is the status of Nanomsg? Is libdill your main focus, or do you grow these projects in parallel? I’ve watched this projects without using them in practice, but I really like the approach of trying to find the right abstractions and patterns for expressive and efficient network programming.
Banal question; libdill? why not just use go?