YUKI Hiroshi
null+****@clear*****
Mon Jan 20 15:23:50 JST 2014
YUKI Hiroshi 2014-01-20 15:23:50 +0900 (Mon, 20 Jan 2014) New Revision: cb6cd2bdb48c523063e74aa80626fe0256a80629 https://github.com/droonga/droonga-client-ruby/commit/cb6cd2bdb48c523063e74aa80626fe0256a80629 Message: Support POST method Modified files: lib/droonga/client/connection/http.rb Modified: lib/droonga/client/connection/http.rb (+12 -3) =================================================================== --- lib/droonga/client/connection/http.rb 2014-01-20 14:48:42 +0900 (afc89d4) +++ lib/droonga/client/connection/http.rb 2014-01-20 15:23:50 +0900 (73e53b7) @@ -125,9 +125,18 @@ module Droonga http.open_timeout = open_timeout http.read_timeout = read_timeout http.start do - # we should support not only GET but POST also... - get = Net::HTTP::Get.new(build_path(message), build_headers(message)) - http.request(get) do |response| + request = nil + case message["method"] + when "POST" + request = Net::HTTP::Post.new(build_path(message), build_headers(message)) + request.body = JSON.generate(message["body"]) + when "GET" + request = Net::HTTP::Get.new(build_path(message), build_headers(message)) + else + raise ArgumentError.new("Unsupport HTTP Method: #{message["method"]}, " + + "in the message: #{JSON.generate(message)}") + end + http.request(request) do |response| yield(response) end end -------------- next part -------------- HTML����������������������������... Download