r-lib / httr2

Make HTTP requests and process their responses. A modern reimagining of httr.
https://httr2.r-lib.org
Other
235 stars 56 forks source link

httr2 equivalent of httr::set_config ? #435

Open cole-brokamp opened 7 months ago

cole-brokamp commented 7 months ago

https://httr2.r-lib.org/reference/index.html

Is there an equivalent way to set global configurations that will be used by all requests?

I'm specifically looking for a way for an R user to set a proxy configuration that would apply to all requests made in an R session.

hadley commented 7 months ago

There's nothing equivalent, but maybe there should be, just for proxies.

cole-brokamp commented 7 months ago

Thanks for confirming! I'll stick with httr for this purpose for now.

cole-brokamp commented 7 months ago

How would you see this being implemented here? I would love to help if possible.

hadley commented 7 months ago

I don't know yet; I need to think about it.

yannikbuhl commented 1 month ago

Hello, I am glad this issue already exists. I would like to second the motion to add something similar to httr::set_config. I use it a lot in scripts where I work with API wrappers based on httr. However, now I am set to work with a R package API wrapper based on httr2 which at the moment does not provide support to add options to the underlying HTTP request through its API, making it necessary to have some way to globally set the configuration.

And in addition to that: Thank you so, so much for all your amazing work here, Hadley!

hadley commented 1 month ago

Out of interest, what sort of options are you looking to set?

yannikbuhl commented 1 month ago

In order to configure my proxy settings I need the following:

It works totally fine used in req_options or req_proxy, however using the package (restatis in my case) I cannot pass these on to the httr2 pipeline used in a non-exported function (we might add support for that later but it would be great if there was a way to globally set the above settings).

hadley commented 1 month ago

Thanks! Definitely something I plan to add when I'm next working on httr2.

hadley commented 3 weeks ago

Would also be useful if you want to set up caching.