-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net_http adapter: Fix to avoid calling configure_ssl
for HTTP connections
#38
Conversation
`env[:ssl]` is an instance of `Faraday::SSLOptions`, and as a result, `configure_ssl` is always executed, even when the connection is to HTTP. Fixes lostisland#37
I've found that the bug also exists in previous versions such as 1.0.1. I'm not sure about the maintenance policy of this library, but I think it would be beneficial to backport the fix to those versions as well. What do you think? |
@@ -42,8 +42,9 @@ def initialize(app = nil, opts = {}, &block) | |||
|
|||
def build_connection(env) | |||
net_http_connection(env).tap do |http| | |||
http.use_ssl = env[:url].scheme == 'https' if http.respond_to?(:use_ssl=) | |||
configure_ssl(http, env[:ssl]) | |||
if env[:url].scheme == 'https' && env[:ssl] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: What if this is even smaller? Making the smallest check first.
if env[:url].scheme == 'https' && env[:ssl] | |
if env[:ssl] && env[:url].scheme == 'https' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, it's not important!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olleolleolle Thank you so much!
configure_ssl
configure_ssl
configure_ssl
configure_ssl
when using a HTTP connection
configure_ssl
when using a HTTP connectionconfigure_ssl
for HTTP connections
@ma2gedev If you can make a backport, I think I can make a release. |
Right, now https://rubygems.org/gems/faraday-net_http/versions/3.1.1 exists. Since CI was stopped, you had no way of seeing the lint issue which was easy to fix. I made the CI start. |
env[:ssl]
is an instance ofFaraday::SSLOptions
, and as a result,configure_ssl
is always executed, even when the connection is to HTTP. This MR fixes the code so that SSL configuration is only performed when necessary, similar to other adapters such as faraday-httpclient and faraday-patron.Details can be found in #37 .