[Groonga-commit] ranguba/groonga-client at 1b207c4 [master] http: extract authentication related code as a method

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Feb 6 23:01:26 JST 2016


Kouhei Sutou	2016-02-06 23:01:26 +0900 (Sat, 06 Feb 2016)

  New Revision: 1b207c422c42e03391703cbb96873d0fa8b63635
  https://github.com/ranguba/groonga-client/commit/1b207c422c42e03391703cbb96873d0fa8b63635

  Message:
    http: extract authentication related code as a method

  Modified files:
    lib/groonga/client/protocol/http/synchronous.rb

  Modified: lib/groonga/client/protocol/http/synchronous.rb (+7 -5)
===================================================================
--- lib/groonga/client/protocol/http/synchronous.rb    2016-02-06 22:59:23 +0900 (6380c2a)
+++ lib/groonga/client/protocol/http/synchronous.rb    2016-02-06 23:01:26 +0900 (945a483)
@@ -112,9 +112,7 @@ module Groonga
             else
               request = Net::HTTP::Get.new(path, headers)
             end
-            if do_authenticate?
-              request.basic_auth(@options[:user], @options[:password])
-            end
+            setup_authentication(request)
             http.request(request)
           end
 
@@ -124,8 +122,12 @@ module Groonga
             }
           end
 
-          def do_authenticate?
-            @options[:user] and @options[:password]
+          def setup_authentication(request)
+            user = @options[:user]
+            password = @options[:password]
+            return if user.nil? or password.nil?
+
+            request.basic_auth(user, password)
           end
         end
       end
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index