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:
parent
bf3d50ab9e
commit
284b69f169
2 changed files with 10 additions and 11 deletions
|
@ -76,9 +76,10 @@ module RestClient
|
|||
else
|
||||
create_regular_field(@stream, k,v)
|
||||
end
|
||||
@stream.write(b + EOL)
|
||||
@stream.write(EOL + b)
|
||||
end
|
||||
@stream.write('--')
|
||||
@stream.write(EOL)
|
||||
@stream.seek(0)
|
||||
end
|
||||
|
||||
|
|
|
@ -20,29 +20,27 @@ describe RestClient::Payload do
|
|||
m.headers['Content-Type'].should == 'multipart/form-data; boundary="123"'
|
||||
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.stub!(:boundary).and_return("123")
|
||||
m.to_s.should == <<-EOS
|
||||
--123\r
|
||||
--#{m.boundary}\r
|
||||
Content-Disposition: multipart/form-data; name="foo"\r
|
||||
\r
|
||||
bar\r
|
||||
--123--\r
|
||||
--#{m.boundary}--\r
|
||||
EOS
|
||||
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")
|
||||
m = RestClient::Payload::Multipart.new({:foo => f})
|
||||
m.stub!(:boundary).and_return("123")
|
||||
m.to_s.should == <<-EOS
|
||||
--123\r
|
||||
Content-Disposition: multipart/form-data; name="foo"; filename="master_shake.jpg"\r
|
||||
--#{m.boundary}\r
|
||||
Content-Disposition: multipart/form-data; name="foo"; filename="./spec/master_shake.jpg"\r
|
||||
Content-Type: image/jpeg\r
|
||||
\r
|
||||
datadatadata\r
|
||||
--123--\r
|
||||
#{IO.read(f.path)}\r
|
||||
--#{m.boundary}--\r
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue