[Groonga-commit] droonga/droonga-client-ruby at 6bf71c8 [master] http: simplify condition

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 20 16:31:23 JST 2014


Kouhei Sutou	2014-01-20 16:31:23 +0900 (Mon, 20 Jan 2014)

  New Revision: 6bf71c812a0893a26d7efe4f0e06313652f89b7d
  https://github.com/droonga/droonga-client-ruby/commit/6bf71c812a0893a26d7efe4f0e06313652f89b7d

  Message:
    http: simplify condition

  Modified files:
    lib/droonga/client/connection/http.rb

  Modified: lib/droonga/client/connection/http.rb (+8 -3)
===================================================================
--- lib/droonga/client/connection/http.rb    2014-01-20 16:30:46 +0900 (727f378)
+++ lib/droonga/client/connection/http.rb    2014-01-20 16:31:23 +0900 (cbc03e3)
@@ -155,9 +155,7 @@ module Droonga
           body = message["body"] || {}
           method = http_method(message)
           base_path = message["path"] || "/#{type}"
-          if body.empty?
-            base_path
-          elsif method == "GET"
+          if use_query_string?(method, body)
             "#{base_path}?#{Rack::Utils.build_nested_query(body)}"
           else
             base_path
@@ -171,6 +169,13 @@ module Droonga
         def http_method(message)
           message["method"] || "GET"
         end
+
+        USE_QUERY_STRING_HTTP_METHODS = ["GET", "HEAD"]
+        def use_query_string?(http_method, parameters)
+          return false if parameters.empty?
+
+          USE_QUERY_STRING_HTTP_METHODS.include?(http_method)
+        end
       end
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



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