[PATCH 1/4] uclient-fetch: --header option to pass additional raw HTTP headers

Andre Heider a.heider at gmail.com
Wed Jun 22 23:20:34 PDT 2022


On 22/06/2022 12:26, Sergey Ponomarev wrote:
> Hi Andre and Jo-Philipp,
> 
> Please add the calloc() error handler yourself because I'm not
> experienced in C and I haven't time. But for you this may be just 5
> minutes.

Sure, I had a look, and while adding that wrapper isn't a problem, the 
patchset itself has an issue:

--header 'Content-type: foo/bar' doesn't work as intended because 
'Content-type: application/x-www-form-urlencoded' is still added too. So 
both headers are sent, which breaks my use case.

I may be looking at that, but I'm time constrained myself too at the moment.

Cheers,
Andre

> The feature is very important from my point of view. The first version
> I sent a year(s?) ago but still no progress.
> If there are any problems please let me know
> 
> On Wed, 22 Jun 2022 at 08:33, Andre Heider <a.heider at gmail.com> wrote:
>>
>> Hi Sergey,
>>
>> any update on this series? I'd be interested in the --header option.
>>
>> Thanks,
>> Andre
>>
>> On 10/05/2022 11:11, Jo-Philipp Wich wrote:
>>> Hi Sergey,
>>>
>>> a minor nitpick inline below.
>>>
>>> On 5/9/22 11:59 PM, Sergey Ponomarev wrote:
>>>> You can add a custom HTTP header(s) to request:
>>>>
>>>>       wget --header='Authorization: Bearer TOKEN' \
>>>>           --header='If-Modified-Since: Wed, 9 May 2021 12:16:00 GMT' \
>>>>           https://example.com/
>>>>
>>>> Some headers like Authorization or User-Agent may be already set by --password or --user-agent.
>>>> We may override them but it's a protection from user itself.
>>>> To keep code concise the logic omitted.
>>>>
>>>> Signed-off-by: Sergey Ponomarev <stokito at gmail.com>
>>>> ---
>>>> [...]
>>>> +                    case L_HEADER:
>>>> +                            if (!raw_headers) {
>>>> +                                    /* Max possible count of headers is the count of args (argc) - 2
>>>> +                                     Since the first arg is program and last is a URL.
>>>> +                                     But user may forget the URL and raw_headers is null terminated so allocate argc */
>>>> +                                    raw_headers = calloc(argc, sizeof(char *));
>>>
>>> Please handle a possible calloc() error here. Maybe consider introducing an
>>> "xalloc()" or similar helper which wraps calloc() and invokes abort() on NULL
>>> return.
>>>
>>>> +                            }
>>>> +                            raw_headers[raw_headers_count] = optarg;
>>>> +                            raw_headers_count++;
>>>> +                            break;
>>>>                       case L_POST_DATA:
>>>>                               post_data = optarg;
>>>>                               break;
>>>> [...]
>>>
>>>
>>> _______________________________________________
>>> openwrt-devel mailing list
>>> openwrt-devel at lists.openwrt.org
>>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>>
> 
> 




More information about the openwrt-devel mailing list