http icon indicating copy to clipboard operation
http copied to clipboard

ssl_context in default options

Open milgner opened this issue 9 years ago • 6 comments

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.

milgner avatar Feb 22 '16 14:02 milgner

client = HTTP.headers(my_headers)
ssl_contexts.each do |ctx|
  res = client.get(url, :ssl_context => ctx)
  # ...
end

ixti avatar Feb 22 '16 16:02 ixti

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?

milgner avatar Feb 22 '16 17:02 milgner

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)

ixti avatar Feb 22 '16 18:02 ixti

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 avatar Feb 22 '16 18:02 tarcieri

@tarcieri why not allow #ssl understand :context as part of params? :D

ixti avatar Feb 22 '16 22:02 ixti

@ixti sure, that works

tarcieri avatar Feb 22 '16 22:02 tarcieri