I like RestClient API very much but it looks to me that I can't configure proxy, timeouts, request hooks, ssl, etc. per request. So for example if I want to execute some requests concurrently in different threads, they may interfere between each other because I've changed some of the configuration.
Am I missing something? Is there a workaround as this seems to me a serious limitation.
Update:
Actually looking at the Request class I think that only proxy configuration and before_execution_procs
are global configuration. Most probably there would be workarounds possible with before_execution_procs
. If you know how to set these per request, I'd be grateful.
example:
(1..10).each {
Thread.new {
RestClient.get(..., proxy: "some proxy", before_execution_hooks: [some, array, of, hooks])
}
}
If I make it like:
(1..10).each {
Thread.new {
RestClient.proxy = "per request proxy"
RestClient.add_before_execution_proc {...}
RestClient.get(...)
}
}
Then I'll end up with unknown proxy per request as well with multiple procs.
You can now set proxy as per request options
With RestClient::Request or with RestClient::Resource which have both :proxy and :before_execution_proc options that override the global settings:
So the following code should be thread safe: