Re: How to dynamically generate UUID in curl command (like macros) before sending http request?

Timothe Litt via curl-users <[email protected]>
Newsgroups gmane.comp.web.curl.general
Message-ID <[email protected]>
Unix uuidgen should use -r  behavior by default if /dev/{u,]random or 
equivalent is available.  It does on the versions that I use.

Otherwise, it uses -t, which is a mix of some hardware (probably primary 
network) MAC and time.  In that case, adding -r won't help.

It's not clear why a request ID would need a guaranteed "high-quality" 
random uuid.

The UUID is most likely for logging/correlating issues with trouble 
tickets or for tying multiple requests together, not crypto.  Any form 
of UUID is going to be good enough for that. (Well, maybe if you are 
generating unique requests faster than the system clock ticks you might 
want to avoid -t.  Seems unlikely.) Anyhow, the default will do the 
right thing on the platforms I use.

Yes, it's  rude to post questions to multiple forums, especially without 
mentioning it.  Wastes everyone's time.


Timothe Litt
ACM Distinguished Engineer
--------------------------
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed.

On 24-May-24 15:16, Ray Satiro via curl-users wrote:
> On 5/24/2024 2:52 PM, Timothe Litt via curl-users wrote:
>>
>> On most Linux/Unix, use uuidgen.
>>
>> curl -X POST -H "x-client-request-id: {$(uuidgen)}" -d '{"a": 1}' 
>> https:/example.com <http://example.com>
>>
>> If you need it for subsequent requests, use
>>
>> UUID="{$(uuidgen)}"
>>
>> curl -X POST -H "x-client-request-id: ${UUID}" -d '{"a": 1}' 
>> https:/example.com <http://example.com>
>>
>> and insert $UUID in the cookie/uri/whatever you need for those requests.
>>
>
> Some uuidgen will not be really random unless you use uuidgen -r I 
> think. Also, this guy asked the same question in the discussions 
> section. [1]
>
> [1]: https://github.com/curl/curl/discussions/13768
>
>

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
OpenPGP_signature.asc (application/pgp-signature, 495 B)
-----BEGIN PGP SIGNATURE-----

wsB5BAABCAAjFiEE0UvvF0GpbrNhifE5DTaRiR4XoSQFAmZQ7TgFAwAAAAAACgkQDTaRiR4XoSRC
1ggAmUaiM9Nb87CDkVU3YDYFyx/sDKPj1D6KRK1chbgfcarFE49srzzzHxOr5g1fPdw63spvNzzu
Z+UdvOXRPefi0/WuAwtW9CxCPBaP3G75o5CSqEnGliH8iyqyttKuHM2pSGgUaNEULSoLSWou78lm
cfudUKYyV7jFM/DH2IAxP7ZrzrOZGAQiEyU9VuibGGZB8HICaY/dNj5IFEgY4vNxuyULcV5Rn/aY
R0bSpSidpp0htWXkA74q8UEwcbOOD48nM2Ri0a55MkQzp/e2cH+WS5E94x81ENkCLNzEH9pkCDao
0BjamP1w4KndIXujkv0NPY0aTIl8DUCBMGdgAzUp7w==
=g5iE
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.