http
http copied to clipboard
ssl_context in default options
My use case: run multiple requests against a single host, using always the same headers (basic auth, accept and content-type) and a custom SSL context.
However I cannot set up the latter: when trying to set ssl_context on the default options, it complains that it's a protected method.
When I do default_options = HTTP::Options.new(ssl_context: ssl_context, ...), all the new default options are set correctly, but ssl_context becomes nil.
client = HTTP.headers(my_headers)
ssl_contexts.each do |ctx|
res = client.get(url, :ssl_context => ctx)
# ...
end
Of course I can specify the SSL context on each request. I just thought it counter-intuitive that it cannot be set as a default option, since that's what default options are supposed to be for?
Oh. That's a good question... @tarcieri @zanker IMO it's a pretty good point. Probably we can provide API like:
client.ssl(ssl_context).get(url)
Yes, however I think we should get away from the #ssl_context API and move towards #ssl_params.
(That's not to say remove the #ssl_context API, just favor #ssl_params)
I would prefer calling the above method #ssl_context, and reserve #ssl for #ssl_params
@tarcieri why not allow #ssl understand :context as part of params? :D
@ixti sure, that works