On 17-Jun-22 09:12, Weston Schmidt via curl-library wrote:
I tend to agree that the existing function signature is a bit too restrictive.If you don't want a unique to WS function, how about adding a different variant across the board for folks? What about adding a CURLOPT_CTX_WRITEFUNCTION where a context object is passed that allows for access back to the curl object & access to metadata that might be specific to that function call, etc. If you want, you could replace the void *userdata with the ctx & then users could make a curl_ctx_get_userdata(ctx) vs add more arguments. For a WS, maybe only CURLOPT_CTX_WRITEFUNCTION is supported, but maybe this is an alternative callback to the existing write() format one? Wes
Or, use the existing callback, but have a CURLOPT to set the handle mode so that the *userdata becomes a protocol-specific structure. The curlopt_set_write_callback_mode could take an enum, like "NORMAL, WEBSOCKET, TELNET (e.g. for urgent data), ..." I would suggest not using an extended_mode ON/OFF type argument since the requirements are likely to evolve.
The struct would have a replacement userdata field, a type code, and a type-specific union of whatever metadata applies.
This avoids creating a new callback and/or a "get metadata" (with the attendant library storage).
Timothe Litt ACM Distinguished Engineer -------------------------- This communication may not represent the ACM or my employer's views, if any, on the matters discussed.
OpenPGP_signature
Description: OpenPGP digital signature
-- Unsubscribe: https://lists.haxx.se/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html
