THRIFT-1599 Fixing HTTP client(Ruby)
authorRoger Meier <roger@apache.org>
Fri, 11 May 2012 18:08:58 +0000 (18:08 +0000)
committerRoger Meier <roger@apache.org>
Fri, 11 May 2012 18:08:58 +0000 (18:08 +0000)
Patch: Tomas

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1337323 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/lib/thrift/transport/http_client_transport.rb
lib/rb/spec/http_client_spec.rb

index 22caf02..1ef0fab 100644 (file)
@@ -43,7 +43,8 @@ module Thrift
     def flush
       http = Net::HTTP.new @url.host, @url.port
       http.use_ssl = @url.scheme == "https"
-      resp, data = http.post(@url.request_uri, @outbuf, @headers)
+      resp = http.post(@url.request_uri, @outbuf, @headers)
+      data = resp.body
       @inbuf = StringIO.new data
       @outbuf = ""
     end
index 959880c..30561ab 100644 (file)
@@ -39,7 +39,11 @@ class ThriftHTTPClientTransportSpec < Spec::ExampleGroup
       Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
         mock("Net::HTTP").tee do |http|
           http.should_receive(:use_ssl=).with(false)
-          http.should_receive(:post).with("/path/to/service?param=value", "a test frame", {"Content-Type"=>"application/x-thrift"}).and_return([nil, "data"])
+          http.should_receive(:post).with("/path/to/service?param=value", "a test frame", {"Content-Type"=>"application/x-thrift"}).and_return do
+            mock("Net::HTTPOK").tee do |response|
+              response.should_receive(:body).and_return "data"
+            end
+          end
         end
       end
       @client.flush
@@ -55,7 +59,11 @@ class ThriftHTTPClientTransportSpec < Spec::ExampleGroup
       Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
         mock("Net::HTTP").tee do |http|
           http.should_receive(:use_ssl=).with(false)
-          http.should_receive(:post).with("/path/to/service?param=value", "test", headers).and_return([nil, "data"])
+          http.should_receive(:post).with("/path/to/service?param=value", "test", headers).and_return do
+            mock("Net::HTTPOK").tee do |response|
+              response.should_receive(:body).and_return "data"
+            end
+          end
         end
       end
       @client.flush