I would like to contribute to uclient-fetch to extend it's functionality and add options that wget have:
--headeroption to pass an additional header e.g.
Authorization: Bearer tokenor
-method=HTTPMethodto able to send DELETE, PUT and other HTTP methods.
--body-data=STRINGto be able to send raw JSON
This few options covers most of use cases when you calling some API. And it should be really easy to implement them without big overhead in size or at least I can make them conditional on build.
In the same time this can help to other packages to use the uclient-fetch which now is about 28Kb instead of curl which is about 280kb.
We can also easily add mapping for curl options and create a uclient-curl as a link to uclient-fetch and thus OpenWrt will have some limited curl out of the box. This is very cool because almost all API documentation uses the curl in examples. This is not a new idea https://curl.haxx.se/mail/archive-2017-09/0020.html and can resolve some issues like this https://github.com/Neilpang/acme.sh/issues/1768
The first patch with the
--header option I already sent to dev list http://lists.infradead.org/pipermail/openwrt-devel/2020-January/021439.html
But it seems to be ignored and also I just don't want to be subscribed to such dev list because it's like drinking from fire hydrant: I received dozen of emails which are not related to uclient-fetch.
I spent my time and wanted to contribute but my patch is lost and nobody will ever remember of it.
That's why I want to discuss this change here because at least I'm sure that core developers will see it.
Why not just create uclient-fetch mirror on github so I can create a usual PR and watch changes?
I made a quick search on github and there is already a lot of clones of uclient-fetch and some with unique commits:
- Unofficial mirrors:
So why not just use GitHub or GitLab? It's 2020 year then why to make life of contributors harder and use mailing list full of garbage?
Ok, sorry for complaining, I have also few things to discuss.
In fact there is some functionality that I propose to remove.
First of all support of Digest Auth: for all my entire life I never saw that is was used anywhere. It makes no sense when using HTTPS and gives just a small security when used over raw HTTP.
So my proposition is to deprecate it and make it conditional on build.
Next thing to remove is Auth challange which was copied from wget: when used basic auth then wget makes two calls: first without credentials, then it checks that server returned 401 and only then it makes the second call with credentials.
This is absolutely useless functionality. I created a ticket in wget bugtracker where descibed why they should remove it: 57686 Basic Auth: make auth-no-challenge mode by default.
I was affected by this functionality I wanted to disable it but uclient-fetch doesn't have the
--auth-no-challenge option. Other OpenWrt users were also confused by this behavior Uclient-fetch and basic auth
So my proposition is just remove this auth challenge functionality. This will make uclient-fetch code much clearer and size a little bit smaller.
Also I'll try to use base64 functions from libubox and remove base64.c file from uclient-fetch so this will make it's size also a little bit smaller.
By removing this unused functionality we can make the uclient-fetch with similar size that it have now while extend it's functionality.
Please tell me if you are ok with my proposed changes and what do you think about them. If you are fine with them then I'll continue my work on uclient-fetch.