summaryrefslogtreecommitdiff
path: root/lib/rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rb')
-rw-r--r--lib/rb/lib/thrift/transport/http_client_transport.rb1
-rw-r--r--lib/rb/spec/http_client_spec.rb15
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/rb/lib/thrift/transport/http_client_transport.rb b/lib/rb/lib/thrift/transport/http_client_transport.rb
index 77ffe3569..c9c4fec8d 100644
--- a/lib/rb/lib/thrift/transport/http_client_transport.rb
+++ b/lib/rb/lib/thrift/transport/http_client_transport.rb
@@ -50,6 +50,7 @@ module Thrift
data = resp.body
data = Bytes.force_binary_encoding(data)
@inbuf = StringIO.new data
+ ensure
@outbuf = Bytes.empty_byte_buffer
end
end
diff --git a/lib/rb/spec/http_client_spec.rb b/lib/rb/spec/http_client_spec.rb
index 793fc73ab..5e8da24b2 100644
--- a/lib/rb/spec/http_client_spec.rb
+++ b/lib/rb/spec/http_client_spec.rb
@@ -67,6 +67,21 @@ describe 'Thrift::HTTPClientTransport' do
end
@client.flush
end
+
+ it 'should reset the outbuf on HTTP failures' do
+ @client.write "test"
+
+ Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
+ mock("Net::HTTP").tap do |http|
+ http.should_receive(:use_ssl=).with(false)
+ http.should_receive(:post).with("/path/to/service?param=value", "test", {"Content-Type"=>"application/x-thrift"}) { raise Net::ReadTimeout }
+ end
+ end
+
+ @client.flush rescue
+ @client.instance_variable_get(:@outbuf).should eq(Thrift::Bytes.empty_byte_buffer)
+ end
+
end
describe 'ssl enabled' do