1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

fix spacing issues with multipart bodies:

* the final boundary should be on a line below the final param's content.
 * the ending double dash should be on the same line as the final boundary
This commit is contained in:
rick 2008-12-10 20:06:10 -08:00
parent bf3d50ab9e
commit 284b69f169
2 changed files with 10 additions and 11 deletions

View file

@ -76,9 +76,10 @@ module RestClient
else else
create_regular_field(@stream, k,v) create_regular_field(@stream, k,v)
end end
@stream.write(b + EOL) @stream.write(EOL + b)
end end
@stream.write('--') @stream.write('--')
@stream.write(EOL)
@stream.seek(0) @stream.seek(0)
end end

View file

@ -20,29 +20,27 @@ describe RestClient::Payload do
m.headers['Content-Type'].should == 'multipart/form-data; boundary="123"' m.headers['Content-Type'].should == 'multipart/form-data; boundary="123"'
end end
xit "should form properly seperated multipart data" do it "should form properly seperated multipart data" do
m = RestClient::Payload::Multipart.new({:foo => "bar"}) m = RestClient::Payload::Multipart.new({:foo => "bar"})
m.stub!(:boundary).and_return("123")
m.to_s.should == <<-EOS m.to_s.should == <<-EOS
--123\r --#{m.boundary}\r
Content-Disposition: multipart/form-data; name="foo"\r Content-Disposition: multipart/form-data; name="foo"\r
\r \r
bar\r bar\r
--123--\r --#{m.boundary}--\r
EOS EOS
end end
xit "should form properly seperated multipart data" do it "should form properly seperated multipart data" do
f = File.new(File.dirname(__FILE__) + "/master_shake.jpg") f = File.new(File.dirname(__FILE__) + "/master_shake.jpg")
m = RestClient::Payload::Multipart.new({:foo => f}) m = RestClient::Payload::Multipart.new({:foo => f})
m.stub!(:boundary).and_return("123")
m.to_s.should == <<-EOS m.to_s.should == <<-EOS
--123\r --#{m.boundary}\r
Content-Disposition: multipart/form-data; name="foo"; filename="master_shake.jpg"\r Content-Disposition: multipart/form-data; name="foo"; filename="./spec/master_shake.jpg"\r
Content-Type: image/jpeg\r Content-Type: image/jpeg\r
\r \r
datadatadata\r #{IO.read(f.path)}\r
--123--\r --#{m.boundary}--\r
EOS EOS
end end
end end