summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Meier <roger@apache.org>2012-05-11 18:08:58 +0000
committerRoger Meier <roger@apache.org>2012-05-11 18:08:58 +0000
commita30930f67708892316bdd6946b13862be4769b2c (patch)
tree86db086e0a2e380a0a93e7a186dbb31550ee94f2 /lib
parentdd16f0538b14109a8ecc710bccd5c02cfa18b313 (diff)
downloadthrift-a30930f67708892316bdd6946b13862be4769b2c.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/rb/lib/thrift/transport/http_client_transport.rb3
-rw-r--r--lib/rb/spec/http_client_spec.rb12
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 22caf022f..1ef0fab5a 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 959880c05..30561ab58 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