Sha256: 0b06e71b1b016542aac2db3730bb518ef29bbbf9ac0dade9904264702989e87e

Contents?: true

Size: 1.99 KB

Versions: 20

Compression:

Stored size: 1.99 KB

Contents

commit 1a1a16d6abda6b40091b49d3ad082400018e665b
Author: rick <technoweenie@gmail.com>
Date:   Wed Dec 10 20:01:02 2008 -0800

    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

diff --git a/lib/rest_client/payload.rb b/lib/rest_client/payload.rb
index dfc2921..e896be0 100644
--- a/lib/rest_client/payload.rb
+++ b/lib/rest_client/payload.rb
@@ -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
 
diff --git a/spec/payload_spec.rb b/spec/payload_spec.rb
index 22b5a5a..35564ee 100644
--- a/spec/payload_spec.rb
+++ b/spec/payload_spec.rb
@@ -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

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
entp-astrotrain-0.2.0 lib/vendor/rest-client/foo.diff
entp-astrotrain-0.2.1 lib/vendor/rest-client/foo.diff
entp-astrotrain-0.3.0 lib/vendor/rest-client/foo.diff
entp-astrotrain-0.3.1 lib/vendor/rest-client/foo.diff
entp-astrotrain-0.4.0 lib/vendor/rest-client/foo.diff
entp-astrotrain-0.4.1 lib/vendor/rest-client/foo.diff
entp-astrotrain-0.4.2 lib/vendor/rest-client/foo.diff
entp-astrotrain-0.4.3 lib/vendor/rest-client/foo.diff
astrotrain-0.5.4 lib/vendor/rest-client/foo.diff
astrotrain-0.5.3 lib/vendor/rest-client/foo.diff
astrotrain-0.5.2 lib/vendor/rest-client/foo.diff
astrotrain-0.5.1 lib/vendor/rest-client/foo.diff
astrotrain-0.5.0 lib/vendor/rest-client/foo.diff
astrotrain-0.4.5 lib/vendor/rest-client/foo.diff
astrotrain-0.4.4 lib/vendor/rest-client/foo.diff
astrotrain-0.4.3 lib/vendor/rest-client/foo.diff
astrotrain-0.4.2 lib/vendor/rest-client/foo.diff
astrotrain-0.4.1 lib/vendor/rest-client/foo.diff
astrotrain-0.4.0 lib/vendor/rest-client/foo.diff
astrotrain-0.3.1 lib/vendor/rest-client/foo.diff