[Groonga-commit] groonga/grntest at cf3543f [master] Use GET for one liner load

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 26 15:42:57 JST 2015


Kouhei Sutou	2015-01-26 15:42:57 +0900 (Mon, 26 Jan 2015)

  New Revision: cf3543fbdc818e1136116ee06cb5c17f1a9410dd
  https://github.com/groonga/grntest/commit/cf3543fbdc818e1136116ee06cb5c17f1a9410dd

  Message:
    Use GET for one liner load

  Modified files:
    lib/grntest/executors/http-executor.rb

  Modified: lib/grntest/executors/http-executor.rb (+14 -6)
===================================================================
--- lib/grntest/executors/http-executor.rb    2015-01-26 15:28:37 +0900 (05ea615)
+++ lib/grntest/executors/http-executor.rb    2015-01-26 15:42:57 +0900 (f1ceda9)
@@ -62,16 +62,24 @@ module Grntest
         Groonga::Command::Parser.parse(command_line)
       end
 
+      MAX_URI_SIZE = 4096
       def send_load_command(command)
-        values = command.arguments.delete(:values)
-        request = Net::HTTP::Post.new(command.to_uri_format)
-        request.content_type = "application/json; charset=UTF-8"
         lines = command.original_source.lines
-        if lines[1].start_with?("[")
-          request.body = lines[1..-1].join
+        if lines.size == 1 and command.to_uri_format.size <= MAX_URI_SIZE
+          return send_normal_command(command)
+        end
+
+        values = command.arguments.delete(:values)
+        if lines.size >= 2 and lines[1].start_with?("[")
+          command.arguments.delete(:columns)
+          body = lines[1..-1].join
         else
-          request.body = values
+          body = values
         end
+
+        request = Net::HTTP::Post.new(command.to_uri_format)
+        request.content_type = "application/json; charset=UTF-8"
+        request.body = body
         response = Net::HTTP.start(@host, @port) do |http|
           http.read_timeout = @read_timeout
           http.request(request)
-------------- next part --------------
HTML����������������������������...
Download 



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