Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated payload to only close if open

  • Loading branch information...
commit d86dae2349236027a8b50738278f1dafdbc43f38 1 parent 40d3641
@pastorius pastorius authored
Showing with 11 additions and 1 deletion.
  1. +1 −1  lib/restclient/payload.rb
  2. +10 −0 spec/payload_spec.rb
View
2  lib/restclient/payload.rb
@@ -91,7 +91,7 @@ def size
alias :length :size
def close
- @stream.close
+ @stream.close unless @stream.closed?
end
def inspect
View
10 spec/payload_spec.rb
@@ -54,6 +54,11 @@
RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s.
should == "foo[]=bar&foo[]=baz"
end
+
+ it 'should not close if stream already closed' do
+ p = RestClient::Payload::UrlEncoded.new({'foo ' => 'bar'})
+ 3.times {p.close}
+ end
end
@@ -63,6 +68,11 @@
m.stub!(:boundary).and_return(123)
m.headers['Content-Type'].should == 'multipart/form-data; boundary=123'
end
+
+ it 'should not error on close if stream already closed' do
+ m = RestClient::Payload::Multipart.new(:file => File.new(File.join(File.dirname(File.expand_path(__FILE__)), 'master_shake.jpg')))
+ 3.times {m.close}
+ end
it "should form properly separated multipart data" do
m = RestClient::Payload::Multipart.new([[:bar, "baz"], [:foo, "bar"]])
Please sign in to comment.
Something went wrong with that request. Please try again.