feat: httr2_translate()
related: https://github.com/r-lib/httr2/issues/500
Very often I need to translate an httr2 command to a curl command to send to the software developers on my team (often java or js devs) to provide a reproducible example of a challenging / troublesome request that I am encountering in R.
While there is a curl_translate() to go from curl -> httr2 it would be exceptionally helpful if there were an httr2 -> curl translation function.
I could also imagine this being helpful for documentation purposes—e.g. having code tabs in a quarto doc one for httr2 and curl and the curl tab is populated by an httr2_translate() of the httr2_request object.
IMO it's going to be hard to justify the work to do this 99% correctly in R given that an LLM will do it for you 95% correctly.
Out of curiosity, how would you go about doing this with an llm? I often use req$body and copy and paste the values into URLdecode() then copy and paste user agent headers etc.
Since requests are created dynamically I don’t really see a straightforward path to using an llm
I just copy and paste the httr2/curl code and ask it to translate.