You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2012/05/11 20:08:59 UTC

svn commit: r1337323 - in /thrift/trunk/lib/rb: lib/thrift/transport/http_client_transport.rb spec/http_client_spec.rb

Author: roger
Date: Fri May 11 18:08:58 2012
New Revision: 1337323

URL: http://svn.apache.org/viewvc?rev=1337323&view=rev
Log:
THRIFT-1599 Fixing HTTP client(Ruby)
Patch: Tomas

Modified:
    thrift/trunk/lib/rb/lib/thrift/transport/http_client_transport.rb
    thrift/trunk/lib/rb/spec/http_client_spec.rb

Modified: thrift/trunk/lib/rb/lib/thrift/transport/http_client_transport.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/lib/thrift/transport/http_client_transport.rb?rev=1337323&r1=1337322&r2=1337323&view=diff
==============================================================================
--- thrift/trunk/lib/rb/lib/thrift/transport/http_client_transport.rb (original)
+++ thrift/trunk/lib/rb/lib/thrift/transport/http_client_transport.rb Fri May 11 18:08:58 2012
@@ -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

Modified: thrift/trunk/lib/rb/spec/http_client_spec.rb
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/rb/spec/http_client_spec.rb?rev=1337323&r1=1337322&r2=1337323&view=diff
==============================================================================
--- thrift/trunk/lib/rb/spec/http_client_spec.rb (original)
+++ thrift/trunk/lib/rb/spec/http_client_spec.rb Fri May 11 18:08:58 2012
@@ -39,7 +39,11 @@ class ThriftHTTPClientTransportSpec < Sp
       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 < Sp
       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