diff --git a/lib/faraday/adapter/net_http_persistent.rb b/lib/faraday/adapter/net_http_persistent.rb index 4396c70..7b74683 100644 --- a/lib/faraday/adapter/net_http_persistent.rb +++ b/lib/faraday/adapter/net_http_persistent.rb @@ -132,7 +132,8 @@ def net_http_connection(env) end def init_options - options = {name: "Faraday"} + options = {} + options[:name] = @connection_options.fetch(:name, "Faraday") options[:pool_size] = @connection_options[:pool_size] if @connection_options.key?(:pool_size) options end diff --git a/spec/faraday/adapter/net_http_persistent_spec.rb b/spec/faraday/adapter/net_http_persistent_spec.rb index 3fea6ca..020d887 100644 --- a/spec/faraday/adapter/net_http_persistent_spec.rb +++ b/spec/faraday/adapter/net_http_persistent_spec.rb @@ -40,6 +40,26 @@ expect(http.pool.size).to eq(5) end + it "allows to set name on initialize" do + url = URI("https://example.com") + + adapter = described_class.new(nil, name: "MyCustomName") + + http = adapter.send(:connection, url: url, request: {}) + + expect(http.name).to eq("MyCustomName") + end + + it "defaults name to Faraday on initialize" do + url = URI("https://example.com") + + adapter = described_class.new(nil) + + http = adapter.send(:connection, url: url, request: {}) + + expect(http.name).to eq("Faraday") + end + it "allows to set verify_hostname in SSL settings to false" do url = URI("https://example.com")