summary refs log tree commit
path: root/test/spec_multipart.rb
diff options
context:
space:
mode:
authorJames Tucker <jftucker@gmail.com>2014-08-03 14:21:41 -0300
committerJames Tucker <jftucker@gmail.com>2014-08-03 14:21:41 -0300
commit9f52bb1db4b007066c9916881001d15c0a61bf66 (patch)
tree8de03740a1339dc367eb258e3e191abf00a91228 /test/spec_multipart.rb
parentd8e2e2af6da57805d2f0906ce925ea150def31a0 (diff)
parent33075a489b85d43fc0be55d3503cc236f349e2f8 (diff)
downloadrack-9f52bb1db4b007066c9916881001d15c0a61bf66.tar.gz
Merge branch 'master' into pr/686
* master: (62 commits)
  build_nested_query includes integer values
  Rack::ETag correctly marks etags as Weak
  Fix yet another body close bug in Rack::Deflater
  Implement full Logger interface on NullLogger
  Revert "support empty string multipart filename"
  support empty string multipart filename
  multipart/form-data with files with no input name
  Fix parent type API regression introduced in #713
  correct weird case regression from #714
  UrlMap: Enable case-insensitive domain matching
  Raise specific exception if the parameters are invalid
  Fix media_type_params when Content-Type parameters contains quoted-strings
  Rack::Multipart::UploadedFile has file extensions
  multipart content-type match now case insensitive
  Undo test that falsely exemplifies production env
  default_middleware_by_environment should always returns empty array for unknown keys
  Remove rbx from Travis' allow_failures
  Fix rbx settings for Travis
  Use latest 2.1 on Travis
  Enable cleanup of Tempfiles from multipart form data by default
  ...

Conflicts:
	lib/rack/request.rb
Diffstat (limited to 'test/spec_multipart.rb')
-rw-r--r--test/spec_multipart.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/spec_multipart.rb b/test/spec_multipart.rb
index 069dc4d2..2acb6e0d 100644
--- a/test/spec_multipart.rb
+++ b/test/spec_multipart.rb
@@ -153,6 +153,18 @@ describe Rack::Multipart do
     params["files"][:tempfile].read.should.equal "contents"
   end
 
+  should "parse multipart upload with text file with no name field" do
+    env = Rack::MockRequest.env_for("/", multipart_fixture(:filename_and_no_name))
+    params = Rack::Multipart.parse_multipart(env)
+    params["file1.txt"][:type].should.equal "text/plain"
+    params["file1.txt"][:filename].should.equal "file1.txt"
+    params["file1.txt"][:head].should.equal "Content-Disposition: form-data; " +
+      "filename=\"file1.txt\"\r\n" +
+      "Content-Type: text/plain\r\n"
+    params["file1.txt"][:name].should.equal "file1.txt"
+    params["file1.txt"][:tempfile].read.should.equal "contents"
+  end
+
   should "parse multipart upload with nested parameters" do
     env = Rack::MockRequest.env_for("/", multipart_fixture(:nested))
     params = Rack::Multipart.parse_multipart(env)
@@ -502,4 +514,28 @@ contents\r
     params["file"][:filename].should.equal('long' * 100)
   end
 
+  should "support mixed case metadata" do
+    file = multipart_file(:text)
+    data = File.open(file, 'rb') { |io| io.read }
+
+    type = "Multipart/Form-Data; Boundary=AaB03x"
+    length = data.respond_to?(:bytesize) ? data.bytesize : data.size
+
+    e = { "CONTENT_TYPE" => type,
+      "CONTENT_LENGTH" => length.to_s,
+      :input => StringIO.new(data) }
+
+    env = Rack::MockRequest.env_for("/", e)
+    params = Rack::Multipart.parse_multipart(env)
+    params["submit-name"].should.equal "Larry"
+    params["submit-name-with-content"].should.equal "Berry"
+    params["files"][:type].should.equal "text/plain"
+    params["files"][:filename].should.equal "file1.txt"
+    params["files"][:head].should.equal "Content-Disposition: form-data; " +
+      "name=\"files\"; filename=\"file1.txt\"\r\n" +
+      "Content-Type: text/plain\r\n"
+    params["files"][:name].should.equal "files"
+    params["files"][:tempfile].read.should.equal "contents"
+  end
+
 end