[Groonga-commit] droonga/droonga-client-ruby at 3cb750f [master] http: use "body" data for HTTP query string and "headers" for HTTP headers

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 20 10:28:09 JST 2014


Kouhei Sutou	2014-01-20 10:28:09 +0900 (Mon, 20 Jan 2014)

  New Revision: 3cb750fac9202051b34ef4b4f990c9585e17b9f9
  https://github.com/droonga/droonga-client-ruby/commit/3cb750fac9202051b34ef4b4f990c9585e17b9f9

  Message:
    http: use "body" data for HTTP query string and "headers" for HTTP headers
    
    Because "body" is also used request specific data in Droonga protocol.

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

  Modified: lib/droonga/client/connection/http.rb (+9 -12)
===================================================================
--- lib/droonga/client/connection/http.rb    2014-01-17 19:09:17 +0900 (039d0e8)
+++ lib/droonga/client/connection/http.rb    2014-01-20 10:28:09 +0900 (c61f580)
@@ -119,7 +119,7 @@ module Droonga
           http.open_timeout = open_timeout
           http.read_timeout = read_timeout
           http.start do
-            get = Net::HTTP::Get.new(build_path(message), options[:headers])
+            get = Net::HTTP::Get.new(build_path(message), build_headers(message))
             http.request(get) do |response|
               yield(response)
             end
@@ -134,22 +134,19 @@ module Droonga
 
         private
         def build_path(message)
-          type = nil
-          parameters = {}
-          message.each do |key, value|
-            if key == "type"
-              type = value
-            else
-              parameters[key] = value
-            end
-          end
+          type = message["type"]
+          body = message["body"] || {}
           base_path = "/#{type}"
-          if parameters.empty?
+          if body.empty?
             base_path
           else
-            "#{base_path}?#{Rack::Utils.build_nested_query(parameters)}"
+            "#{base_path}?#{Rack::Utils.build_nested_query(body)}"
           end
         end
+
+        def build_headers(message)
+          message["headers"] || {}
+        end
       end
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



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