[PATCH uclient] uclient-fetch: allow to overwrite Content-Type header for POST

Andre Heider a.heider at gmail.com
Sun Jun 20 00:01:03 PDT 2021


On 19/06/2021 10:37, Baptiste Jonglez wrote:
> Hi,
> 
> On 03-06-21, Andre Heider wrote:
>> This is required by some APIs, e.g. matrix's media upload [0].
>>
>> [0] https://matrix.org/docs/spec/client_server/latest#post-matrix-media-r0-upload
> 
> 
>> @@ -484,6 +485,7 @@ static int usage(const char *progname)
>>   		"	--user-agent | -U <str>		Set HTTP user agent\n"
>>   		"	--post-data=STRING		use the POST method; send STRING as the data\n"
>>   		"	--post-file=FILE		use the POST method; send FILE as the data\n"
>> +		"	--content-type=STRING		use STRING as Content-Type for the POST method\n"
>>   		"	--spider | -s			Spider mode - only check file existence\n"
>>   		"	--timeout=N | -T N		Set connect/request timeout to N seconds\n"
>>   		"	--proxy=on | -Y on		Enable interpretation of proxy env vars (default)\n"
> 
> As far as I can tell, GNU wget does not have such an option.  We try to
> stay compatible whenever possible, so adding a new custom option is not
> a good idea.

Right, this does not exist in wget.

> How would you solve this problem with GNU wget?  Reading the man,
> --post-data and --post-file are really meant to transmit data in
> "application/x-www-form-urlencoded" format, not as arbitrary data.  But if
> it is still possible with a custom --header for instance, we should be
> able to do the same in uclient-fetch.

Yup, that would be
--header=STRING             insert STRING among the headers
wget --header 'Content-Type: foo'

Which is possible to add to uclient-fetch, but the patch will be bigger 
(I tried to keep it as small as possible without hacks).

I'll look into it.

> Otherwise, maybe curl will do a better job at this.

I'm trying to use OpenWrt's base tools to keep the dependencies to a 
minimum, that would defeat the purpose :(

Thanks!
Andre



More information about the openwrt-devel mailing list