curl config file based on domain or inline variables based on request

Bastian Jesuiter via curl-users <[email protected]> Thu, 11 Dec 2025 10:39:58 +0100
Newsgroups gmane.comp.web.curl.general
Message-ID <CAL07qPXw3=tEzfTHisBZuVr3xvL1tEZHdup5N6NDryc8fJNo4w@mail.gmail.com>
--===============4272120544718726904==
Content-Type: multipart/alternative; boundary="0000000000003c9e8e0645a9ee2c"

--0000000000003c9e8e0645a9ee2c
Content-Type: text/plain; charset="UTF-8"

Hi,

Just had a thought.

I regularly find myself using curl with authorization bearer tokens.
However since I cannot use .netrc for bearer tokens,
I tried to find another solution to automatically add them without needing
to include them manually each time.

The idea is to potentially use a combination of curlrc + file based headers
with -H @file

The curlrc would include the a header with a {{ domain }} like variable
syntax.

Like:
header @path/{{domain}}.txt

Where the domain will be inferred by the given domain in the command.

Example:
curl --url "https://example.com" --header @curl/{{domain}}.txt

Where domain resolves to example.com automatically. Because then I could
put the --header arg into curlrc.

Alternatively, what if @file could link to a bashscript to make this
dynamic?

Although a bash script might have insane security implications I do not
forsee at the moment.

Thanks

Bastian

--0000000000003c9e8e0645a9ee2c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Hi,<div dir=3D"auto"><br></div><div dir=3D"auto">Just had=
 a thought.=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto">I regu=
larly find myself using curl with authorization bearer tokens.=C2=A0</div><=
div dir=3D"auto">However since I cannot use .netrc for bearer tokens,=C2=A0=
</div><div dir=3D"auto">I tried to find another solution to automatically a=
dd them without needing to include them manually each time.=C2=A0</div><div=
 dir=3D"auto"><br></div><div dir=3D"auto">The idea is to potentially use a =
combination of curlrc + file based headers with -H @file</div><div dir=3D"a=
uto"><br></div><div dir=3D"auto">The curlrc would include the a header with=
 a {{ domain }} like variable syntax.</div><div dir=3D"auto"><br></div><div=
 dir=3D"auto">Like:</div><div dir=3D"auto">header @path/{{domain}}.txt</div=
><div dir=3D"auto"><br></div><div dir=3D"auto">Where the domain will be inf=
erred by the given domain in the command.</div><div dir=3D"auto"><br></div>=
<div dir=3D"auto">Example:</div><div dir=3D"auto">curl --url &quot;<a href=
=3D"https://example.com">https://example.com</a>&quot; --header @curl/{{dom=
ain}}.txt=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto">Where do=
main resolves to <a href=3D"http://example.com">example.com</a> automatical=
ly. Because then I could put the --header arg into curlrc.=C2=A0</div><div =
dir=3D"auto"><br></div><div dir=3D"auto">Alternatively, what if @file could=
 link to a bashscript to make this dynamic?=C2=A0</div><div dir=3D"auto"><b=
r></div><div dir=3D"auto">Although a bash script might have insane security=
 implications I do not forsee at the moment.=C2=A0</div><div dir=3D"auto"><=
br></div><div dir=3D"auto">Thanks=C2=A0</div><div dir=3D"auto"><br></div><d=
iv dir=3D"auto">Bastian=C2=A0</div></div>

--0000000000003c9e8e0645a9ee2c--

--===============4272120544718726904==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html

--===============4272120544718726904==--