Skip to content

Commit

Permalink
Merge pull request #4 from expandrive/master
Browse files Browse the repository at this point in the history
Ruby 1.9 support
  • Loading branch information
danabr committed Aug 21, 2012
2 parents 3ae7c27 + cf41881 commit 133c57e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/multipart_parser/parser.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def init_with_boundary(boundary)


@boundary_chars = {} @boundary_chars = {}
@boundary.each_byte do |b| @boundary.each_byte do |b|
@boundary_chars[b] = true @boundary_chars[b.chr] = true
end end
end end


Expand Down Expand Up @@ -137,7 +137,7 @@ def write(buffer)
# See http://debuggable.com/posts/parsing-file-uploads-at-500- # See http://debuggable.com/posts/parsing-file-uploads-at-500-
# mb-s-with-node-js:4c03862e-351c-4faa-bb67-4365cbdd56cb # mb-s-with-node-js:4c03862e-351c-4faa-bb67-4365cbdd56cb
while i + boundary_length <= buffer_length while i + boundary_length <= buffer_length
break if boundary_chars.has_key? buffer[i + boundary_end] break if boundary_chars.has_key? buffer[i + boundary_end].chr
i += boundary_length i += boundary_length
end end
c = buffer[i, 1] c = buffer[i, 1]
Expand Down
3 changes: 1 addition & 2 deletions test/multipart_parser/parser_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ def parser.boundary_chars; @boundary_chars end


parser.init_with_boundary("abc") parser.init_with_boundary("abc")
assert_equal "\r\n--abc", parser.boundary assert_equal "\r\n--abc", parser.boundary
expected_bc = {13 => true, 10 => true, 45 => true, 97 => true, expected_bc = {"\r"=>true, "\n"=>true, "-"=>true, "a"=>true, "b"=>true, "c"=>true}
98 => true, 99 => true}
assert_equal expected_bc, parser.boundary_chars assert_equal expected_bc, parser.boundary_chars
end end


Expand Down

0 comments on commit 133c57e

Please sign in to comment.