From a30930f67708892316bdd6946b13862be4769b2c Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Fri, 11 May 2012 18:08:58 +0000 Subject: [PATCH] THRIFT-1599 Fixing HTTP client(Ruby) 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 | 3 ++- lib/rb/spec/http_client_spec.rb | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/rb/lib/thrift/transport/http_client_transport.rb b/lib/rb/lib/thrift/transport/http_client_transport.rb index 22caf022..1ef0fab5 100644 --- a/lib/rb/lib/thrift/transport/http_client_transport.rb +++ b/lib/rb/lib/thrift/transport/http_client_transport.rb @@ -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 diff --git a/lib/rb/spec/http_client_spec.rb b/lib/rb/spec/http_client_spec.rb index 959880c0..30561ab5 100644 --- a/lib/rb/spec/http_client_spec.rb +++ b/lib/rb/spec/http_client_spec.rb @@ -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 -- 2.17.1